Hey,
I try to add in my collection one object (JSON) resulted by an api (https://docs.magicthegathering.io/).
Exemple api result :
{
"card":{
"name":"Narset, Enlightened Master",
"manaCost":"{3}{U}{R}{W}",
"cmc":6,
"colors":[
"White",
"Blue",
"Red"
],
"type":"Legendary Creature — Human Monk",
...
}
}
After i use this : result.card
for remove the ‘card’ level, and result be that :
{
"name":"Narset, Enlightened Master",
"manaCost":"{3}{U}{R}{W}",
"cmc":6,
"colors":[
"White",
"Blue",
"Red"
],
"type":"Legendary Creature — Human Monk",
...
}
And when i try to add in mongo collection like that :
Meteor.call('cards.add', card);
...
Meteor.methods({
'cards.add': function (doc) {
Cards.insert({
doc
});
}
});
The result is like that in database, with ‘doc’ field, and i dont want that field :
{
"_id" : "ukmwWkFQtLFPuGwPz",
"doc" : {
"name" : "Narset, Enlightened Master",
"manaCost" : "{3}{U}{R}{W}",
"cmc" : 6,
"colors" : [
"White",
"Blue",
"Red"
],
"colorIdentity" : [
"W",
"U",
"R"
],
"type" : "Legendary Creature — Human Monk",
...
}
}
How can i have just all my fileds same level as _id ? Thanks