我得到一个错误TypeError:当我想在我的financial.deposit内推值时,无法设置未定义的属性'financial.deposits‘,该值是我的MongoDB集合用户中的字段;
const query = {};
query["$push"]["financial.deposits"] = {
hello: "hello"
}
await UserModel.update({ _id: key }, query).exec();我试过了,但它抛出了异常。
发布于 2019-08-06 20:58:14
您的查询应如下所示:
const query = {$push:{"financial.deposite":{['key1']:"anything"}}};
db.usertest.update({ "_id" : ObjectId("5d4976ac1f28f608707dba3c")}, query)https://stackoverflow.com/questions/57375352
复制相似问题