I have this schema on my node.js app. I'm using mongoose:
var todoSchema = new Schema({
task: String,
description: String,
date: Date,
status: String,
checklist: Boolean,
user: String
});
I want to get this result, so I can pass it into google chart and display it on chart:
[
{
"user": "A",
"detail" :
[
"open" : 3,
"progress" : 5,
"done" : 7
"archive" : 10
]
},
{
"user": "B",
"detail" :
[
"open" : 4,
"progress" : 9,
"done" : 14
"archive" : 12
]
}
]
But my query looks wrong:
Todo.find().distinct( "user", function(err, users){
Todo.find({"user": {"$in": users}}, function(err, todo){
if (err)
res.send(err);
var finalResult = [];
finalResult.push(todo);
res.send(finalResult);
//res.send(todo);
});
});
});
Anybody can help me, please? Really appreciated your help.