Reputation: 7008
I have a query that was working with older version:
await this.model.findOne({ userEmail, 'environments.envId': envId },{ 'environments.$': envId })
But I get error here at environments.$
. I am not finding anything related to this error on web.
Upvotes: 0
Views: 884
Reputation: 705
With $ projections You can only use a number. The following code will work:
await this.model
.findOne({
userEmail,
'environments.envId': envId
},
{
'environments.$': 1
})
more info here: https://docs.mongodb.com/manual/reference/operator/projection/positional/
Upvotes: 1