带有点表示法的MongoDB $ inc会产生错误(Atlas Server)

时间:2017-08-05 18:21:59

标签: mongodb

我有以下MongoDB更新...

DB.collection('counter').findOneAndUpdate(
       { _id: _id },
       { $inc: { 'events.598398c37a9e22304bb197fa.count': 1 } },
       (e,d) => {
       console.log(e);
    })

这似乎有效,$ inc有效,但产生以下错误......

Error: key _events:598398c37a9e22304bb197fa.count must not contain '.'
at Error (native)
at serializeInto (/home/node_modules/bson/lib/bson/parser/serializer.js:731:19)
at serializeObject (/home/node_modules/bson/lib/bson/parser/serializer.js:294:18)
at serializeInto (/home/node_modules/bson/lib/bson/parser/serializer.js:754:17)
at serializeObject (/home/node_modules/bson/lib/bson/parser/serializer.js:294:18)
at serializeInto (/home/node_modules/bson/lib/bson/parser/serializer.js:754:17)
at serializeObject (/home/node_modules/bson/lib/bson/parser/serializer.js:294:18)
at serializeInto (/home/node_modules/bson/lib/bson/parser/serializer.js:596:17)
at serializeObject (/home/node_modules/bson/lib/bson/parser/serializer.js:294:18)
at serializeInto (/home/node_modules/bson/lib/bson/parser/serializer.js:754:17)

任何建议欢迎。

0 个答案:

没有答案