【发布时间】:2013-07-13 21:01:43
【问题描述】:
我正在尝试使用 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"] } ] }
唯一的区别是,当我检索它时,会少三个模块,并且我将一些新的模块添加到数组中。
很想听听任何想法,至少关于错误的含义!
【问题讨论】:
标签: node.js mongodb mongoose database