【发布时间】:2015-01-29 21:33:02
【问题描述】:
使用环回模型挂钩,我知道您可以在使用 beforeCreate 创建之前访问像 User 这样的模型实例:
User.beforeCreate = function(next, userInstance) {
//your logic goes here using userInstance
next();
};
但是如果我需要添加一些使用刚刚创建的用户的名字的应用程序逻辑,我该怎么做呢?
User.afterCreate = function(next) {
//I need access to the user that was just created and some of it's properties
next();
};
有没有办法获取刚刚创建的用户,或者我是否需要更改我的应用逻辑以使用之前而不是之后?
【问题讨论】:
标签: node.js model hook loopbackjs strongloop