所以我有一个带有mongo设置的基本测试数据库。以下是
users
集合当前看起来像:
{
"_id" : ObjectId("5d8e23ed2f8849a57711e48e"),
"firstName" : "Joe",
"lastName" : "Black",
"email" : "joeblack@gmail.com",
"portfolio" : [ ],
"watchlist" : [ ],
"goals" : [ ],
"badges" : [ ],
"ranks" : [ ],
"hasPortfolio" : false,
"hasWatchlist" : false,
"hasGoals" : false
}
{
"_id" : ObjectId("5d8e23ed2f8849a57711e48f"),
"firstName" : "Juan",
"lastName" : "Gonzales",
"email" : "juangonzales@outlook.com",
"portfolio" : [ ],
"watchlist" : [ ],
"goals" : [ ],
"badges" : [ ],
"ranks" : [ ],
"hasPortfolio" : false,
"hasWatchlist" : false,
"hasGoals" : false
}
{
"_id" : ObjectId("5d8e338fe0562db42af793c9"),
"firstName" : "Foo",
"lastName" : "Bar",
"email" : "foobar@baz.com",
"portfolio" : [ ],
"watchlist" : [ ],
"goals" : [ ],
"ranks" : [ ],
"badges" : [
{
"name" : "Tester",
"type" : "bronze",
"new" : true
}
],
"hasPortfolio" : false,
"hasWatchlist" : false,
"hasGoals" : false
}
我要做的是更新
portfolio
用户数组
foobar@baz.com
. 但我一直有以下错误:
2019-09-27t13:07:00.590-0500 e查询[js]syntaxerror:missing}在属性列表@(shell):6:8之后
命令
db.users.update({email: 'foobar@baz.com'}, {
$set: {
portfolio: [
{
availableSupply: "1000000"
currency: "SHIT"
exchange: "Binance",
exchange_base: "btc",
marketCap: 10000,
name: "ShitCoin",
percentage: 100,
price: 0.01,
position: 1,
value: 0.01,
inWatchlist: false
}
]
}
})