How to deal with the timezone issue when storing dates in utc using mongod?

Aside from the SERVER-6310 mentioned by Matt Johnson, one other workaround is to use the $project operator to add or subtract from the UTC time zone to “shift the time” into the correct local zone. Turns out you can add or subtract time in milliseconds. For example, assuming I have a Date field called orderTime. … Read more

MongoDB: count the number of items in an array

In MongoDB 2.6, the Aggregation Framework has a new array $size operator you can use: > db.mycollection.insert({‘foo’:[1,2,3,4]}) > db.mycollection.insert({‘foo’:[5,6,7]}) > db.mycollection.aggregate([{$project: { count: { $size:”$foo” }}}]) { “_id” : ObjectId(“5314b5c360477752b449eedf”), “count” : 4 } { “_id” : ObjectId(“5314b5c860477752b449eee0”), “count” : 3 }

tech