I have a twice nested schema:
mongoose.model('Team', mongoose.Schema(
{
players : [{
trikots : [{
isNew : Boolean,
color : String
}]
}]
})
For now, my query looks like this:
Team.aggregate()
.match({'_id' : new ObjectId(teamId)})
.unwind('players')
.unwind('players.trikots')
.match({'players.trikots.isNew' : 'red', 'players.trikots.isNew' : true})
.exec(sendBack);
But I would like to have one Team object, that contains all players as an array. How can I achieve that?