Mongoose findOneAndUpdate
method by default returns the document that has been updated. If you were adding a sub document in a given document, the returned document will contain all the sub documents in that document. Is there a built-in mechanism within MongoDB/Mongoose, to return the recently added sub document alone instead of all the sub documents as part of the returned callback? Currently am having to 'manually' search for the sub document I have just added, which I find inefficient as the database increases in size.
Asked
Active
Viewed 31 times
0

Sean
- 360
- 3
- 17
-
https://stackoverflow.com/questions/54424239/how-to-return-elements-with-the-most-recent-date-in-mongodb – Ezra Siton Oct 31 '20 at 13:11
-
Does the above guarantee accuracy of data in the case where two records share the same timestamp? – Sean Oct 31 '20 at 13:23