我正在尝试使用Mongoose的findOneAndUpdate函数向Mongo文档编写更新。基本上,我有一个包含另一个模式数组的文档,当我尝试添加更多这种模式类型时,我会收到以下错误:
[Error: Invalid atomic update value for $__. Expected an object, received object]
我很难理解这个错误的含义,更不用说它的来源了。
我尝试更新的数据如下:
{ section_id: 51e427ac550dabbb0900000d,
version_id: 7,
last_editor_id: 51ca0c4b5b0669307000000e,
changelog: 'Added modules via merge function.',
committed: true,
_id: 51e45c559b85903d0f00000a,
__v: 0,
modules:
[ { orderId: 0,
type: 'test',
tags: [],
data: [],
images: [],
content: ["Some Content Here"] },
{ orderId: 1,
type: 'test',
tags: [],
data: [],
images: [],
content: ["Some Content Here"] },
{ orderId: 2,
type: 'test',
tags: [],
data: [],
images: [],
content: ["Some Content Here"] },
{ orderId: 3,
type: 'test',
tags: [],
data: [],
images: [],
content: ["Some Content Here"] },
{ orderId: 4,
type: 'test',
tags: [],
data: [],
images: [],
content: ["Some Content Here"] },
{ orderId: 5,
type: 'test',
tags: [],
data: [],
images: [],
content: ["Some Content Here"] } ] }
唯一的区别在于当我检索它时,有三个模块没有了,并且我将一些新模块添加到数组中。
很想听听任何想法,至少知道这个错误意味着什么!