node.js - Mongoose/MongoDB Aggregation - $match $unwind $match not working? -


How do I change this archive-collections: Integrate from.view.archive also: Really?

.. When stopping the collection of duplicate messages .. If the user (sessionUser) is present in the array, then only get one of these messages.

  If (collection == = true) {console.log ('collection ===' + true); Models.Message.gregate ([// match documents {"$ match": {"to": {"$ elemMatch": {"username": req.Session.username, "view.archive": true, "view. Bin ": false}}," $ or ": messagingquery}}, // {" $ unwind ": Open" $ to unwind "to normalize, // match array elements {" $ match " : {"To.view.archive": true, "to.view.bin": false}}, the original group {"$ group": {"_id"}: {"to" user.name ":" user name ": req.session.username," to.view.archive " : "", "From": {"$ first": "from $ i"}, "to": {"$ push": "$ to"}, "message": {"$ first": "$ {"$ First": "$ first": "$ timesent"}, "answer": {"$ first": "$ replies"}, "messaging": {"$ first": "$ messaging"}}} , // Sort by update, most recent first (descending) {"$ sort": {"updated": -1}}], function Not (accidentally, message) {if (err) {console.log (err); res.send (fault);} Res.json ({message: Session User: Session user});}); }  

UserMessageSchema & amp; Looks like this for both; For the arrays of MesageSchema:

  var UserMessageSchema = new schema ({user: {"type": Schema.ObjectId, "ref": "user"}, user name: string, view: {Inbox: boolean, outbox: boolean, collection: boolean, bin: boolean}, read: {marked: {"type": boolean, default: wrong}, date time: date}, updated: date});  

I think I should have some misconception about the situation, but it It seems like it should be able to add a simple $ or to the first match phase:

  {"$ match": {"$ or": [[" : "{$ $ ElemMatch"}: {"username": req.session.username, "view.archive": true, "view.bin": false}}}, {"to": {"$ elemMatch": { "Username": Req.session.username, "view.archive": true,}}}], "$ or": messagingquery}}  

the result of duplication $ Match phase, since $ match documents based on a condition Where does the duplication come from and what exactly is a "duplicate" defined?


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -