【发布时间】:2017-08-13 18:42:20
【问题描述】:
我有一个看起来像这样的通知模型
"use strict";
module.exports = function(Notification) {
};
我还有另一个模型是 Post:
"use strict";
module.exports = function(Post) {
Post.prototype.postLike = function(options, cb) {
this.likes.add(options.accessToken.userId);
cb(null, "sucess");
};
Post.remoteMethod("postLike", {
isStatic: false,
accepts: [{ arg: "options", type: "object", http: "optionsFromRequest" }],
returns: { arg: "name", type: "string" },
http: { path: "/like", verb: "post" }
});
}
我想要的是在通知模型中添加 post 的 afterRemote 方法?
是否可以环回?
它应该看起来像:
"use strict";
module.exports = function(Notification) {
var app = require("../../server/server.js");
var post = app.models.Post;
post.afterRemote('prototype.postLike', function(context, like, next) {
console.log('Notification after save for Like comment');
});
};
但这不起作用。
注意:我可以自己发布模型,但我想在通知模型中添加我的所有通知逻辑以简化和未来定制。
【问题讨论】:
标签: loopbackjs strongloop loopback