Mongoose文档没有"保存"方法 - 但是,确实如此

Sem*_*lon 5 javascript mongoose mongodb node.js

迭代返回的一组文档时Model.find(),我将每个结果文档传递给另一个最终调用该save()方法的函数.但我得到这个错误:

[TypeError: Object #<Object> has no method 'save']
Run Code Online (Sandbox Code Playgroud)

我已经确认有问题的对象是Mongoose文档.事实上 - 这真让我感到困惑......

console.log(order.save); // { [Function] numAsyncPres: 0 }
order.save(); // [TypeError: Object #<Object> has no method 'save']
Run Code Online (Sandbox Code Playgroud)

我甚至不明白这是怎么可能的,因为它存在直到我称之为......

如果需要的话,我会提供更多的上下文代码,但是我正在指责这是一些已知的奇怪/愚蠢的疏忽,我可以立即认出.

编辑:在查看错误堆栈时,我看到它正在调用save.否则,我会看到完全不同的错误消息.相反,save方法无法找到内部保存方法.这是堆栈:

at C:\dev\node_modules\mongoose\lib\document.js:1272:13
at Array.forEach (native)
at model.pre.err.stack (C:\dev\node_modules\mongoose\lib\document.js:1254:12)
at model._next (C:\dev\node_modules\mongoose\node_modules\hooks\hooks.js:50:30)
at model.proto.(anonymous function) [as save] (C:\dev\node_modules\mongoose\node_modules\hooks\hooks.js:96:20)
at fixNoPriceItem (C:\dev\unimatrix\node_modules\cathy.js:202:10)
at Array.forEach (native)
at CallManager.callback (C:\dev\unimatrix\node_modules\cathy.js:181:18)
at Object.tracker.complete (C:\dev\unimatrix\node_modules\mowse\node_modules\constructors\Call-Manager.js:80:8)
at continueHandling (C:\dev\unimatrix\node_modules\mowse\node_modules\constructors\Call-Manager.js:138:14)
Run Code Online (Sandbox Code Playgroud)

实际调用的函数order.save是fixNoPriceItem第六个函数.

保存前对文档的唯一更改如下:

order.items[targetIndex] = itemData; // items is an arr
order.markModified('items');
Run Code Online (Sandbox Code Playgroud)

我怀疑这与我如何设置子文档有关...