what I am trying to do is find most recent 5 records, and project specific feilds only (which is 'createdAt' and 'transactionType') below is my MongoDB Collection's schema.
| Key | Type |
|---|---|
| createdAt | String |
| timestamp | Date |
| ... | ... |
| transactionLogs_docs | Array |
| - [0] | Object |
| - transactionType | String |
and the following is the query that I am trying to get the result that I want..
db.getCollection('integrated_transaction_logs').find({}, {createdAt:true, transactionLogs_docs(0).transactionType:true}).sort({timestamp:-1}).limit(5); any tip or advice for this....? :S
https://stackoverflow.com/questions/65622912/how-can-i-filter-fields-to-show-in-result-with-the-value-that-is-in-array-in-m January 08, 2021 at 11:07AM
没有评论:
发表评论