如何在 Strongloop 中使用 MongoDB 运算符

How to use MongoDB operators in Strongloop

我想使用 $inc 来更新模型(用户)的属性,但我发现了两个问题。找不到参数allowExtendedOperators:true,也不知道这样写对不对:

common/user.js

user.updateAttribute('coins',{ '$inc': {coins: -1} }, function(err,...);

common/user.json

"name": "user",
"base": "User",
"strict": true,
"idInjection": true,
"options": {
   "validateUpsert": true
}, 
...  
"settings": {
    "mongodb": {
      "allowExtendedOperators": true
    }
  },

我尝试了这个但是没有任何反应...

server/datasource.development.js

"MongoDB": {
    "host": "...",
    "port": "..."
    "database": "...",
    "name": "MongoDB",
    "connector": "mongodb",
    "allowExtendedOperators": true
  }

我在 documentation StrongLoop 上寻找,唯一的例子是制作一个 updateAll 并说:

There are two ways to enable the allowExtendedOperators flag: in the model definition JSON file and as an option passed to the update method.

但对我没有任何作用..

调用方法如下:

user.updateAttributes({"$inc": {coins: -1}}, callback);

尽管回调总是return递减前的旧实例。