Reputation: 1312
I have a database schema that looks like:
{
foreignKeyId: String
question: String
...: ...
answers: [
{
answerText: String
isCorrect: Boolean
}
,
...
]
}
I now want a find()-Query that queries a document by foreignKeyId and only contains the fields foreignKeyId, question and answers.$.answerText.
As I use MeteorJS I am not able to return anything else than a cursor to the database.
When I filter it like {fields: {foreignKeyId: 1, "answers.$.answerText":1}}
I get an error that the projection does not match my Query
Upvotes: 0
Views: 40
Reputation: 1312
I found a solution.
It is not
db.find(query, {fields: {"array.$.subkey": 1}});
it is
db.find(query, {fields: {"array.subkey": 1}});
Upvotes: 1