【发布时间】:2014-05-01 07:57:47
【问题描述】:
我相信我看到有人写过一种从模型对象中获取内存对象以减少数据库访问的方法。有人可以建议或分享文件吗?
我想要这样的东西:
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.
});
});
提前谢谢你!
【问题讨论】: