【发布时间】:2011-01-03 13:06:45
【问题描述】:
我在尝试更新 Mongo 中的字段时收到“不允许使用修饰符重复字段名称”错误。一个例子:
> db.test.insert({test: "test1", array: [0]});
> var testFetch = db.test.findOne({test: "test1"});
> db.test.update(testFetch,
{$push: {array: 1}, //push element to end of key "array"
$pop: {array: -1} //pop element from the start of key "array"
});
Field name duplication not allowed with modifiers
有没有办法执行这个原子操作?我不想为此做两个单独的更新。
【问题讨论】:
-
这是我遇到此错误时的第一个谷歌结果。我的问题,使用猫鼬,原来是这样的:github.com/LearnBoost/mongoose/issues/1933
标签: mongodb