The last question for today that I have been collecting for half a year)
My simple collection:
{
_id: 1,
books: [
{ bookId: 55, otherfields },
{ bookId: 66, otherfields },
]
}
How i can use position and $first both ?
c.findOne({_id: 1, 'books.bookId': 66}, { projection: {_id:0, book: { $first:'$books.$'} }});
get error :
MongoServerError: Unsupported projection option: book: { $first: “$books.$” }
c.findOne({_id: 1, 'books.bookId': 66}, { projection: {_id:0, book: { $first:'$books'} }});
get error:
MongoServerError: Unsupported projection option: book: { $first: "$books" }
I use latest mongodb and driver