Sailsjs Model.update不能在控制器中工作

只是一个快速的初学者问题…

控制器是否允许在Sails中执行更新? 我知道行动路线,但是我不能得到这样的代码来更新。

//controller code (this DOES NOT update) Packets.update({packet:5},{cron:'locationhistory'}) .then( function(r){ console.log(r); }); 

这个过程起作用,所以我很困惑,为什么上面不会。

 //controller code that does work, however I'm calling a custom function sails.models.packets.updateMyPacket('locationhistory', 9, function( response ){ console.log(response); }); // model code updateMyPacket: function( p, num, cb) { Packets.update({ cron: p}, {packet: num}).then( function( packets){ cb(packets); }); 

}

任何人都可以帮忙吗? 我错过了什么?

谢谢Matt

在你的例子中,你有你的标准和你的价值观在两种不同的方法之间交换。