Skip to content

Instantly share code, notes, and snippets.

View bateloche's full-sized avatar

João Bateloche bateloche

View GitHub Profile
/* 1 */
{
"_id" : ObjectId("572a529051e56dd889ff93f1"),
"name" : "Bob",
"scores" : [
{
"type" : "Homework",
"score" : 2
},
{
db.students.aggregate([{
$project:{
_id: false,
name:'$name',
finalScore: {
$reduce: {
input: '$scores',
initialValue: 0,
in: { $add: ['$$value', '$$this.score'] }
}
{
"_id": 1,
"Nome": "NoSql By Example",
"ISBN": "021546365487",
"Alugueis":[{
"idSocio": 1,
"nomeSocio": "João",
"data": "2016-05-03T21:26:00.000Z-03:00"
},{
"idSocio": 2,
[{
"_id":1,
"nome": "João",
"cpf": "58306803191"
},{
"_id":2,
"nome":"José",
"cpf":"00942995368"
}]