我有通知模型看起來像這樣迴環:如何添加模型的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模型本身,但我想補充我所有的通知邏輯的通知模型簡化和未來的定製。
我會檢查一下。有沒有什麼辦法可以在沒有啓動腳本的情況下在模型中執行它?或者像我應該在我的所有模型加載後檢查它。 –