Tag: loopbackjs

回环与i18n支持

我想了解如何添加国际化的支持,以build立在express.js之上的回环。 我已经安装了i18n-node并阅读了express.js文档。 它看起来像我不想要一个全球性的本地化,因为我将提供HTTP响应。 i18n-node文档build议将其附加到请求对象并给出一个示例。 我的问题是,我无法find哪里/如何将此代码添加到环回。 我试着把app.configuration函数放在任何地方,它说这个方法是不确定的。 我有一种感觉,这是一个中间件,我想添加到路由阶段的middleware.json文件。 但我不知道该怎么做。 有谁知道国际化回送应用程序的好方法(服务器响应消息,电子邮件出去等)?

slc:loopback:没有这样的文件或目录

在Ubuntu 15.04上,我通过“npm install -g strongloop”安装了strongloop,并安装了heimdal-multidev,我得到了以下结果: $ slc –version slc(Heimdal 1.6.99)版权所有1995-2014 Kungliga TekniskaHögskolan发送错误报告至heimdal-bugs@h5l.org $ slc 用法:slc [–version] [–help]命令表 $ slc loopback slc:loopback:没有这样的文件或目录 $ node -v V5.4.0 $ npm -v 3.3.12 回环有什么问题? 非常感谢!

环回 – RestAPI路由下的自定义路由

我试图在我的restAPI根目录下添加一个自定义的快速路由,但是当试图到达这个地址时找不到。 例如,如果其余的/api根目录是/api ,那么下面的自定义路由是不可访问的(我想用/api/sayHello调用方法/api/sayHello ): app.get('/api/sayHello', function (req, res, next) { res.send('hello!'); } ); 我得到的错误是: “错误”: {“name”:“Error”,“status”:404,“message”:“没有方法处理GET / sayHello”,“statusCode”:404,“stack”:“错误:没有办法处理GET / sayHello \ n restUrlNotFound(/workspace/sandboxlauncher/node_modules/strong-remoting/lib/rest-adapter.js:337:17)\n在Layer.handle作为handle_request \ n在trim_prefix(/ workspace / project_folder / node_modules /express/lib/router/index.js:312:13)\n at /workspace/project_folder/node_modules/express/lib/router/index.js:280:7\n在Function.process_params(/ workspace / project_folder / (/workspace/project_folder/node_modules/express/lib/router/index.js:271:10)\n在jsonParser(/ workspace / node_modules / express / lib / router / index.js:330:12) (/workspace/project_folder/node_modules/express/lib/router/index.js:\ project_folder / node_modules / body-parser […]

环回的跳过和限制filter不与filter一起使用

我正在使用Loopback框架开发我的REST API。 我在我的应用程序中使用分页的概念,因为我使用Loopback的文档build议的跳过和限制filter。 但是,当我用这些filter与wherefilter,我没有得到预期的结果。 这是我的代码: router.get('/', function(req, res) { var filter = { where: {feedId: req.query.id}, limit : req.query.limit, skip : req.query.skip }; var Feeds = server.models.feeds; Feeds.find(filter, function(err, feeds) { res.send(feeds); }); }); 当我们单独使用它时,filter的使用和限制都是完美的。 有人有主意吗? 我怎样才能使它工作?

LoopBack访问另一个模型

这是情况: 我有三个模型我的数据库: 口袋妖怪/口袋妖怪types/types 口袋妖怪通过口袋妖怪types链接到一个或多个types。 所以现在我想要一个函数来获得链接到给定口袋妖怪的types: module.exports = function(Pokemon) { Pokemon.types = function(id, cb){ var PokemonType = Pokemon.app.models.pokemonType.find(); var Type = Pokemon.app.models.type.find(); var arrayTypes = []; // var result = app.models.pokemonType.find({where : {"pokemon_id": id}}); // for(var x in result){ // var typeId = x.pokemonType_id; // var results = Type.find({where: {"id": typeId}}); // arrayTypes.push(results); // } cb(null, […]

错误:无法迁移未附加到此数据源的模型:loopback-datasource-juggler

我指的是下面的链接来设置环回框架,并创build简单的API https://docs.strongloop.com/display/public/LB/Getting+started+with+LoopBack 但是,当我尝试将API连接到数据源时,出现以下错误:获取原因以及如何解决此问题。 请任何人都可以帮我解决这个问题。 Error: Cannot migrate models not attached to this datasource: CoffeeShop at /Users/emotian/Development/loopback-getting-started/node_modules/loopback-datasource-juggler/lib/datasource.js:822:14 at nextTickCallbackWith0Args (node.js:420:9) at process._tickDomainCallback (node.js:390:13) at process.fallback (/Users/emotian/Development/loopback-getting-started/node_modules/loopback/node_modules/continuation-local-storage/node_modules/async-listener/index.js:450:15) at Function.Module.runMain (module.js:443:11) at startup (node.js:139:18) at node.js:968:3

在Loopback自定义远程方法中通过多部分表单文件处理file upload

我已经尝试了一切推荐在我怎样才能用LoopBack身体分析器? 但仍然没有运气。 我的客户端应用程序在AngularJS中,使用ng-file-upload模块,具体如下: Upload.upload({ url: apiUrl + '/Recipes/uploadImage', file: $scope.picFile, params: { recipeId: newRecipe.id } }) .then(function(res) { console.log('succes:', res); }, function(err) { console.log('error:', err); }, function(evt) { console.log('progress:', evt); }); 在服务器(Loopback)方面,我确定server/middleware.json已经注册了中间件: … "parse": { "body-parser#json": {}, "body-parser#urlencoded": {"params": { "extended": true }} }, … 对于好的方法,尽pipe我不确定除了multer是否还需要body-parser(因为在middleware.json中注册了body-parser),我已经把这些行包含在server/server.js : var bodyParser = require('body-parser'); var multer = require('multer'); […]

Loopback HasManyThrough关系只能以一种方式工作

我有两个模型“Jobdetails”和“工作渠道”,通过模型“JobDetailsHasVenues”具有“HasManyThrough”关系 Jobdetails型号: { "name": "Jobdetails", "properties": { "jobname": { "type": "String", "required": true, "length": 250, "precision": null, "scale": null, "mysql": { — }, "_selectable": false } }, "relations": { "jobvenues": { "type": "hasMany", "model": "Jobvenues", "foreignKey": "jobdetailsId", "through": "JobdetailsHasVenues" } } 和工作模式如下: { "name": "Jobvenues", "properties": { "storename": { "type": "String", "required": true, "length": 200, […]

在nodejs loopback中安排一个cron作业

如何在具有环回框架的nodejs中安排cron作业。 在服务中,我定义了API从API进入模块并执行操作。 但是我不知道如何在app.js文件中安排它。 var http = require('http'); var schedule = require('node-schedule'); var j = schedule.scheduleJob('* * * * *', function(){ console.log('The answer to life, the universe, and everything!'); }); 我试过这个,但没有运行。

strongloop / loopback / heroku“inq”运算符在本地服务器上正常工作,但不在Heroku上

如果我没有inq运算符运行 /api/Installations?filter[where][userId]=572d7995a80e6d0300b3f812 结果如下 [ { "appId": "myApp", "userId": "572d7995a80e6d0300b3f812", "deviceToken": "cjxfuAfldZ4:APA91bFwK6FTqGCgShU4cdk4mPMlFPhevhFTEzsRELUVt5lARYKvhxI8jb55SVCveYf3zjXel3Kb7JrAyoHv6e8Aob8M0SEdepRWrckKliS2Iyh3bWHWH8EIBOp", "deviceType": "android", "status": "active", "id": "572d7996a80e6d0300b3f813", "created": "2016-05-07T05:13:58.564Z", "modified": "2016-05-07T05:13:58.564Z" } ] 但是现在,如果我运行相同的查询与inq运算符如下 /api/Installations?filter={"where": {"userId": {"inq": ["572d7995a80e6d0300b3f812"]}}} 它给了我空的结果没有任何错误。 我浪费了好几个小时,却找不到可能的原因。 请帮助我….谢谢。