moogoose aggregate $match does not work with ObjectId

32 views
Skip to first unread message

Shawn Fisk

unread,
Jun 15, 2017, 1:44:41 PM6/15/17
to Mongoose Node.JS ODM
billing_model.aggregate()
.match({ 'accoundOid': new mongoose.Types.ObjectId('57264747183a9cf2411896d2') })
.group({ _id: '$service', time: { $sum: { $subtract: [ '$end', '$start' ] } } })
.exec (err, result) ->
if err then return done(err)
done(null, result)
true

Can not match based on ObjectId, the results set to mongodb is 

db.billings.aggregate([ { $match: { accountOid: 57264747183a9cf2411896d2 } }, { $group: {_id: "$service", time: { $sum: { $subtract: [ "$end", "$start" ] } } } } ]);



Which does not working, you must of ObjectId around accountOid value.

Reply all
Reply to author
Forward
0 new messages