Following code does not seem to work, I receive undefined function. Using co-monk which is based on mongoskin which is based on the mongodb native node module.
Document:
{
"_id" : ObjectId("560c24b853b558856ef193a4"),
"name" : "ирина",
"pic" : "",
"language" : ObjectId("560c24b853b558856ef193a2"),
"cell" : 1,
"local" : {
"email" : "ирина@mail.com",
"password" : "12345"
},
"sessions" : [
{
"id" : ObjectId("560c24b853b558856ef193a5")
}
]
}
Query:
var sessionSeen =
yield users.aggregate([
{
$match: {
_id: myVarIdHere
}
},
{
$project: {
_id: 0,
data: {
$map: {
input: '$sessions',
as: 'sess',
in : '$$sess.seen'
}
}
}
}
]);
seen
is supposed to return null as it hasen't been set.