从loopback文档中可以看出:
beforeRemote()和afterRemote()都具有相同的签名; 下面的语法使用beforeRemote但afterRemote是相同的。 对于静态远程方法,包括自定义远程方法:
modelName.beforeRemote( methodName, function(ctx, next) { ... next(); });
然后文件继续说......
静态方法具有URL / api / modelName / methodName,而原型方法具有URL / api / mod elName / id / methodName。
在其他地方,提供了一个例子
module.exports = function(Review) { Review.beforeRemote('create', function(context, user, next) { var req = context.req; req.body.date = Date.now(); req.body.publisherId = req.accessToken.userId; next(); }); };基于上面的文档...我希望create是一个静态方法,因此只有两个参数(但在上面的例子中,实际上, beforeRemote for create有三个参数。
是否有不同的定义或静态方法列表?
From the loopback documentation it states that:
Both beforeRemote() and afterRemote() have the same signature; below syntax uses beforeRemote but afterRemote is the same. For static remote methods, including custom remote methods:
modelName.beforeRemote( methodName, function(ctx, next) { ... next(); });
The documentation then goes on to say ...
Static methods have URL /api/modelName/methodName, while prototype methods have URL /api/mod elName/id/methodName.
Elsewhere, an example is provided
module.exports = function(Review) { Review.beforeRemote('create', function(context, user, next) { var req = context.req; req.body.date = Date.now(); req.body.publisherId = req.accessToken.userId; next(); }); };Based on the above documentation ... I would expect that create would be a static method and therefore only have two arguments (but yet in this example above, and in practice, beforeRemote for create has three arguments.
Is there a different definition or a list of a static methods available?
最满意答案
我认为这是文档中的错误,因为PersistedModel.create是一个静态方法。
静态和实例方法的列表在参考文档中:
https://apidocs.strongloop.com/loopback/v/2.27.0/#persistedmodel
I think this is an error in the documentation, since PersistedModel.create is a static method.
A list of static and instance methods is in the reference docs:
https://apidocs.strongloop.com/loopback/v/2.27.0/#persistedmodel
更多推荐
发布评论