Foo
是我的MongoDB
collection
。 在那裏,我只有一個document
:流星。 MongoDB upsert錯誤:TypeError:keypath.split不是函數。 (in'keypath.split('。')','keypath.split'is undefined)
{
0: {code: "basic", caption: "basic", points: 100},
1: {code: "gold", caption: "gold", points: 200},
2: {code: "platinum", caption: "platinum", points: 300},
3: {code: "diamond", caption: "diamond", points: 400},
id: "PnpbhFi8m7NqZXRr6"
}
當我試圖upsert
它,我收到以下錯誤:
TypeError: keypath.split is not a function. (In 'keypath.split('.')', 'keypath.split' is undefined)
這是我的代碼:
const data = [
{
"code": "basic",
"caption": "basic",
"points": 100
},
{
"code": "gold",
"caption": "gold",
"points": 200
},
{
"code": "platinum",
"caption": "platinum",
"points": 300
},
{
"code": "diamond",
"caption": "diamond",
"points": 400
}
];
const doc = Foo.findOne();
Foo.upsert(doc._id, { $set: data });
哪裏是我的錯誤?
是您的意圖有'data'是對象的數組或數字鍵嵌套對象? –