0
我想添加到我的mongoDB中的現有數組。這裏是我有什麼,但它當然是不正確的,因爲所有的數據已被清除出它試圖將其添加後:MongoJS添加到現有的陣列
db.cardKeeper.update(
{_id: ObjectId('5621c5ac30895e5776e4d1ea')},
{
$push:{'cardKeeperApp.appData.cardDecks':deckObject}
}
)
deckObject
這是我想添加到數組對象看起來像這樣
var deckObject = {
name: productName,
searchName: productItem,
price:{
purchasePrice: productCost,
averageWorth: priceAverageFixed,
lowWorth: lowestSoldAmount,
highWorth: highestSoldAmount
}
}
,正如你所看到cardKeeperApp.appData.cardDecks
是我的數組持有更多信息,看起來就像deckObject
如果它幫助這裏是完整的對象,我想添加到cardDecks
陣列。我已將空白標記爲空
{
"_id" : ObjectId("5635ddf82f4c220f4f932af2"),
"cardKeeperApp" : {
"appData" : {
"cardDecks" : [
{
"name" : "Some Name",
"searchName" : "Some+Name",
"price" : {
"purchasePrice" : null,
"averageWorth" : null,
"lowWorth" : null,
"highWorth" : null
}
}
],
"allDeckTotalWorth" : null
}
}
}