After experimenting with mongodb for a few days, I've encountered a problem that I'm struggling to explain concisely.
The issue arises when my mongodb Collection creates an autoindex, which I want it to do. However, when I insert JSON data like this:
var body // contains JSON data
collection.insert({
body
});
The resulting object in my Collection ends up structured like this:
{
"_id" : ObjectId("59621dfb13eecc8a083d3951"),
"body" : {
"name" : "leaf",
"type" : 2
}
}
What I actually want it to look like is:
{
"_id" : ObjectId("59621dfb13eecc8a083d3951"),
"name" : "leaf",
"type" : 2
}
Any assistance or guidance on achieving this desired structure would be greatly appreciated. Thank you for taking the time to help!