I got a problem with finding lines in a structure made of objects and arrays.
Here is my mongoose schema :
var subscriberSchema = mongoose.Schema({
chkpt: {
subDocs:[
{
id: String,
newValues: {
attributes:[
{
_id: {
name: String
},
value: [
{
string: String
}
]
}
]
}
}
]
}
});
And here is the request i try to apply on that schema :
Subscriber.find({'chkpt.modifiedSubDocs.newValues.attributes.id.name':'blabla'}, 'chkpt.modifiedSubDocs.newValues.attributes.value.string', function (err, subscribers) {
if (err) return handleError(err);
// Prints the json
res.json(subscribers);
The problem is that the returned json contains every attributes arrays that contains at least one "blabla" in its ids. I would like it to return only the value that corresponds to the line of 'attributes' array which has the id named "blabla".
If you know a method to do that, don't hesitate ;)
Thanks,
Bowbow