Hey guys, I have a Project schema with an array of subdocuments (entries).
entries: [EntrySchema]
This EntrySchema has some data such as: username, email…
What Im trying to do is, with a given username, i need to pull out the EntrySchema of that user inside the array. (I mean, retrieve only the EntrySchema information of that user).
I tried the following query:
const exists = await Project.findOne({_id:id,owner,"entries.username":username}, {"entries.$": 1}).exec();
But the problem is, this query returns the whole project schema, with all entries for example, instead of only the information of the entry of the username Im querying…
How can I do that?