mongoodb 操作数组有毒!
我定义了一个数组结构 ,如下:
imgUrls: { type: Array }
我在更新的时候使用 save( )
方法,之后就疯狂的给我保错:
{ MongoError: An empty update path is not valid.
at Function.MongoError.create (/Users/yangyss/Desktop/Cool/git/react-koa/node_modules/mongodb-core/lib/error.js:31:11)
at toError (/Users/yangyss/Desktop/Cool/git/react-koa/node_modules/mongodb/lib/utils.js:114:22)
at /Users/yangyss/Desktop/Cool/git/react-koa/node_modules/mongodb/lib/collection.js:1049:67
at /Users/yangyss/Desktop/Cool/git/react-koa/node_modules/mongodb-core/lib/connection/pool.js:455:18
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
name: 'MongoError',
message: 'An empty update path is not valid.',
driver: true,
index: 0,
code: 56,
errmsg: 'An empty update path is not valid.' }
想问一下大家是怎么操作数组的,我想随意替换数组,比如:
[1,2,3]
更新成 [4,5,6]