Tag: 强循环

在回送authentication失败节点js中扩展用户模型

我已经扩展了loopback的用户模型,以使其与我的自定义用户模型一起工作。 这是用户模型(自定义模型)文件 { "name": "user", "base": "User", "options": { "idInjection": false, "mysql": { "schema": "BANNERG", "table": "User" } }, "properties": { "id": { "type": "Number", "required": true, "length": null, "precision": 10, "scale": 0, "id": 1, "mysql": { "columnName": "id", "dataType": "int", "dataLength": null, "dataPrecision": 10, "dataScale": 0, "nullable": "N" } }, "accId": { "type": "Number", […]

使用带有环回的非rest呼叫(强循环)

我们为我们的REST API使用了Loopback,并希望通过相同的实例来实现一些标准的Node Express类似的调用,这些调用不会通过Loopback框架自动路由。 我们如何添加一个新的单独的路线而不会干扰环回路由? 以下是标准的Loopback启动代码: var loopback = require('loopback'); var boot = require('loopback-boot'); var app = module.exports = loopback(); // Bootstrap the application, configure models, datasources and middleware. // Sub-apps like REST API are mounted via boot scripts. boot(app, __dirname); app.start = function() { // start the web server return app.listen(function() { app.emit('started'); console.log('Web server […]

如何在Loopback中添加更多的RemoteMethod到内置模型(比如说User)

如何在Loopback中添加更多的RemoteMethod到内置模型(比如说User)? 我已经创build了一个common / models / user.js并添加了下面的代码 var loopback = require('loopback'); var User = loopback.User; User.signup = function(userData, callback){ // Validate data // Save data – User // Create role mapping // return token } User.remoteMethod( 'signup', { accepts: [{ arg: 'userData', type: 'object' }], returns: { arg: 'token', type: 'object' }, http: { verb: 'post' […]

Node.js周期性任务与集群

我在生产模式下运行StrongLoop的Loopback API服务器。 这意味着主进程会创build尽可能多的工人,你的CPU有多less核心。 因此,主进程只控制工作人员,永远不执行你的代码。 我的目的是当时只执行一次定期任务,因为现在它运行在所有4名工作人员身上。 除了cron或Redis类存储中的“密钥locking”之外,是否有任何build议?

使用loopback-connector-remote在另一个回送服务中调用自定义方法不会创build正确的URL

我试图连接2回送服务,让我们说A和B ,使用loopback连接器远程数据源。 在B我有这个自定义的远程方法: /api/B/myModel/myMethod/{id} 如果我访问B服务的API资源pipe理器,此方法工作正常。 然后在一个服务上,我想访问这个方法,所以我在远程模型对象上创build了以下configuration(在B上也是这样): myModel.remoteMethod( 'myMethod', { http: {path: '/myMethod/:id', verb: 'get'}, accepts: [ {arg: 'id', type: 'number', required: true} ], returns: {type: 'object', root: true} } ); 从A我可以做任何调用B,如find,findById等,但是当我调用这个自定义的方法,我得到这个错误在A : strong-remoting:rest-adapter GET / myModel / myMethod / 1231错误:错误:id必须是一个数字 看看B中的日志,我看到A正在调用这样的服务: strong-remoting:rest-adapter GET / myModel / myMethod /中的错误:id?id = 1231:错误:id必须是数字 为什么强远程或loopback-connector-remote在创buildURL时不能正确replaceid? 我错过了什么configuration?

loopback.io模型,acl principalId,$ owner

我只需要将模型中的数据访问限制到创build它的环回用户。 我在文档中看到了这一点: http://loopback.io/doc/en/lb2/Model-definition-JSON-file.html#acls $owner – Owner of the object 这是否意味着创build该对象的login用户? 当模型运行create时,loopback.io将当前login用户的用户标识存储在自己的ACL中? 或者我需要做这样的事情,就是在我的模型上创build与用户模型关系的新属性: ACL遇到loopback.io问题

环回资源pipe理器内联模型需要模型模式

我坚持我的remoteMethods不显示在Loopback Explorer中的默认值。 如果我input一个JSON对象,这个post将会创build,但是通常会有一个示例“Model Schema”。 这里只是说内联模型。 有任何想法吗? 模型定义: { "name": "PicklistModel", "plural": "PicklistModels", "base": "PersistedModel", "idInjection": true, "options": { "validateUpsert": true }, "properties": { "picklistId": { "type": "string", "id": true, "generated": true }, "key": { "type": "string", "required": false }, "value": { "type": "string", "required": false } }, "validations": [], "relations": {}, "acls": [], "methods": {} […]

我可以使用按位运算符来请求Loopback模型吗?

Strongloop Loopback文档没有提到任何有关使用按位筛选器进行对象检索的内容。 例如在Loopback API文档中 : // Just an example of syntax, it does not do bitwise filter Inventory.find({where: {status: {gt: 4}}); 直接连接到MongoDB ,我可以这样做: // Select items with 3rd bit on in `status` field db.inventory.find({status: {$mod: [4, 0]}}); 我可以在Loopback模型接口后面做同样的事吗? 在MongoDB文档中,他们说$是条件可以做同样的事情,而更昂贵 : db.inventory.find( { $where: "this.qty % 4 == 0" } ) 我可以在回送中执行以下操作: Inventory.find({where: "this.qty % 4 […]

Strongloop:如何使用代码(而不是REST API)获取相关模型

无法在User对象上获取相关模型。 Users与Customers有多对多的关系。 我可以不只是说User.customers抓住与customers关联的customers ? 我努力了 User.find({include:'customers'}, function(err, user) { //now what? //user.customers does not work; there is no Customer array returned. }); 很高兴看到这个文件,但我找不到这是写在哪里。 谢谢

如何在环回中制定API限速策略

我只是想为每个帐户计划制定一个API请求速率限制,假设我们有用户和每个用户都有一个计划,每天有多lessAPI请求可以制定。 那么现在,我怎样才能在环回3.x的API限制政策。 谢谢