node.js - Aggregate: return document with no subdocument OR with latest subdocument only -


this more complex version of the query in question

i've got these mongoose schemas:

var thread = new schema({     title: string, messages: [message] }); var message = new schema({     date_added: date, author: string, text: string }); 

how return threads latest message subdocument (limit 1) , threads without message subdocuments well?


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -