Yes, you can sum all the elements for tS.1 but only because it's a
named field here (not an array index):
> db.array.find()
{ "_id" : ObjectId("53f27c63b841c46daea2ca19"), "acct" : 1, "asOf" :
ISODate("2012-07-14T00:00:00Z"), "ccy" : "USD", "gc" : 1, "tS" : [ {
"1" : [ 0, 1, 2, 3 ] }, { "2" : [ 0, 1, 2, 3 ] }, { "3" : [ 0, 1, 2, 3
] } ] }
{ "_id" : ObjectId("53f27c70b841c46daea2ca1a"), "acct" : 1, "asOf" :
ISODate("2012-07-14T00:00:00Z"), "ccy" : "USD", "gc" : 2, "tS" : [ {
"1" : [ 0, 1, 2, 3 ] }, { "2" : [ 0, 1, 2, 3 ] }, { "3" : [ 0, 1, 2, 3
] } ] }
{ "_id" : ObjectId("53f27c7db841c46daea2ca1b"), "acct" : 1, "asOf" :
ISODate("2012-07-14T00:00:00Z"), "ccy" : "USD", "gc" : 3, "tS" : [ {
"1" : [ 0, 1, 2, 3 ] }, { "2" : [ 0, 1, 2, 3 ] }, { "3" : [ 0, 1, 2, 3
] } ] }
> db.array.aggregate({$unwind:"$tS"},{$unwind:"$tS.1"}, {$group:{_id:1,sum1:{$sum:"$tS.1"}}})
{ "_id" : 1, "sum1" : 18 }
Asya
> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user"
> group.
>
> For other MongoDB technical support options, see:
>
http://www.mongodb.org/about/support/.
> ---
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
mongodb-user...@googlegroups.com.
> To post to this group, send email to
mongod...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/mongodb-user.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/mongodb-user/80948efe-92b5-4a84-8ef1-43c1f8693e3b%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.