Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 希望在节点中使用sails增加mongodb中的字段值_Node.js_Mongodb_Sails.js - Fatal编程技术网

Node.js 希望在节点中使用sails增加mongodb中的字段值

Node.js 希望在节点中使用sails增加mongodb中的字段值,node.js,mongodb,sails.js,Node.js,Mongodb,Sails.js,我想在使用sails(节点)的更新查询中将字段值增加1 这是唯一正确的方法 Users.update({ code: referral }, { $inc: { referredCount: 1 } }) 如果未递增,请检查文档中是否存在referedCount。 如果存在,则检查其是否嵌套在另一个对象中。 最后,通过下面的查询检查是否存在所应用过滤器的实际文档 Users.find({ code: referral }) 请尝试{$inc:{referedCount:1}}@sushant

我想在使用sails(节点)的更新查询中将字段值增加1


这是唯一正确的方法

Users.update({ code: referral }, { $inc: { referredCount: 1 } })
如果未递增,请检查文档中是否存在referedCount。
如果存在,则检查其是否嵌套在另一个对象中。
最后,通过下面的查询检查是否存在所应用过滤器的实际文档

Users.find({ code: referral })

请尝试{$inc:{referedCount:1}}@sushantmehta Notworking@AbhishekBansal您的模式或数据是什么样子的?这是用户模型中的字段。您是否能够使用用户找到记录。查找({code:reference})?请检查更新的代码。我认为您应该将转介写为“转介”,如果不是动态的,我可以使用用户查找记录。查找和转介是动态的
Users.find({ code: referral })