i have a question about getting specific data out of a mongo db. The Data in the DB are very big and there are many objects in it. The objects have the following architecture:
{
"_id": ObjectId("XXXX"),
"app_id": "XXXXXX",
"title": "The title",
"os": "OS",
"crash": [{
"crash_reason": {
"updated_at": "2018-06-28T03:39:47Z",
...many values ...
},
"crashes": [{
...many values ...
},
{
...many values ...
}],
"status": "success",
}, {
"crash_reason": {
"updated_at": "2018-06-28T03:39:46Z",
...many values ...
},
"crashes": [{
...many values ...
},
{
...many values ...
}],
"status": "success",
}],
"status": "success",
}
so... to get all object i am just using my db and then do this:
db.crashes.find()
But, i want to get all objects but only with specific data. The output should look like this (if possible).
{
"_id": ObjectId("XXXX"),
"app_id": "XXXXXX",
"title": "the title",
"os": "OS",
"crash": [{
"crash_reason": {
"updated_at": "2018-06-28T03:39:47Z" }
}]
}
Sadly i am new to mongo and try to find a solution with the documentation but with no success. i tryed many things, for example:
db.crashes.find([{$group:{app_id: "$app_id",title: "$title",os: "$os", crash: { $first: "$updated_at" }}}])
db.crashes.aggregate([{$group:{app_id: "$app_id",title: "$title",os: "$os", crash: { $first: "$updated_at" }}}])
is it even possible? I would also be satisfied with the following output :-D
{
"_id": ObjectId("XXXX"),
"app_id": "XXXXXX",
"title": "the title",
"os": "OS",
}
can someone please help me? :-)