我有通知模型看起来像这样回环:如何添加模型的afterRemote到另一种模式
"use strict";
module.exports = function(Notification) {
};
我有另一种模式是邮政:
"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" }
});
}
我要的是在通知模型里面添加PostRemote方法?
是否有可能在回送?
它不应该是这样的:
"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');
});
};
但是,这是行不通的。
注:我能做到这一点Post模型本身,但我想补充我所有的通知逻辑的通知模型简化和未来的定制。
我会检查一下。有没有什么办法可以在没有启动脚本的情况下在模型中执行它?或者像我应该在我的所有模型加载后检查它。 –