Model Sailjs/Waterline-有没有办法获取以前获取的对象?

Model Sailjs/Waterline-有没有办法获取以前获取的对象?,model,sails.js,waterline,Model,Sails.js,Waterline,我相信我看到有人写过一种从模型对象获取内存中对象的方法,以减少对数据库的访问。请有人告诉我或与我分享这份文件好吗 我想要这样的东西: ModelA.create({...}).populate('modelBs').exec(function(err, instanceA) { // Do some nested things here, for example: instanceA.prop1 = someNewValue; instanceA.save(functio

我相信我看到有人写过一种从模型对象获取内存中对象的方法,以减少对数据库的访问。请有人告诉我或与我分享这份文件好吗

我想要这样的东西:

ModelA.create({...}).populate('modelBs').exec(function(err, instanceA) {
    // Do some nested things here, for example:
    instanceA.prop1 = someNewValue;
    instanceA.save(function(err, instanceAModified) {
       // I want to call some method from instanceAModified, to get all 'modelB' objects here, without accessing the DB once more.
    });
});

提前谢谢你

我相信在最新版本的Waterline中,
.save()
将重新填充其回调中的所有关联。但无论如何,您可以通过将它们保存在局部变量中来始终保留它们。假设您指的是上面的
查找
而不是
创建
(因为
填充
创建
上没有任何操作):


知道了。谢谢!
ModelA.find({...}).populate('modelBs').exec(function(err, instanceA) {
    // Do some nested things here, for example:
    instanceA.prop1 = someNewValue;
    var modelBs = instanceA.modelBs;
    instanceA.save(function(err, instanceAModified) {
       // modelBs will still be available here.
    });
});