loopbackjs

LoopbackJS 3.x, how to enable delete all matching instances

别来无恙 提交于 2019-12-24 07:45:01
问题 By default in Loopback delete all matching instances is not exposed over REST API. How to enable it? 回答1: I couldn't find any reference to the documentation, but I successfully tested this. TLDR: Put in this in your model.js or in server.js app.models.<model>.remoteMethod('destroyAll', { description: 'Delete all matching records.', accessType: 'WRITE', accepts: [ {arg: 'where', type: 'object', description: 'filter.where object'}, {arg: 'options', type: 'object', http: 'optionsFromRequest'}, ]

Loopback - getting function back instead of values

百般思念 提交于 2019-12-24 02:30:38
问题 For some endpoints I get a function back when called instead of the actual values (code at the end). It looks like that it only appears for nested endpoints through my Patient model. E.g. localhost:3000/api/Patients/{id}/MeasDescPatRels However this works fine: localhost:3000/api/Patients/{id}/MeasuredDataPoints In my webapp it is not really a problem, apparently the returned function is just called by JS and gives me the correct data. However I have an android app calling the exact same

Why is node require cache filling up and leaking

萝らか妹 提交于 2019-12-23 13:12:21
问题 Im stress testing an API in loopback which is transpiled with Babel. However, during these longer "smoke" tests, we have seen the require cache in Heap analysis growing quite large (up to 1gb) and does not get GCd. I understand the require cache wont GC until the last reference is removed, but why would it continue to grow if Im calling the same set of methods over and over? Could this be an issue with Babel 6, or NodeJS 4.4.3? Here is a screen shot showing the heap dump 回答1: We were hitting

How to change http status codes in Strongloop Loopback

◇◆丶佛笑我妖孽 提交于 2019-12-23 10:59:28
问题 I am trying to modify the http status code of create. POST /api/users { "lastname": "wqe", "firstname": "qwe", } Returns 200 instead of 201 I can do something like that for errors: var err = new Error(); err.statusCode = 406; return callback(err, info); But I can't find how to change status code for create. I found the create method: MySQL.prototype.create = function (model, data, callback) { var fields = this.toFields(model, data); var sql = 'INSERT INTO ' + this.tableEscaped(model); if

How can I get the slc command to work on Ubuntu?

送分小仙女□ 提交于 2019-12-23 09:38:37
问题 I have installed Strongloop using npm install -g strongloop on my Ubuntu 14.04 server. The slc command does not work. It says The program 'slc' is currently not installed. You can install it by typing: sudo apt-get install heimdal-multidev How can I get it to run the Strongloop CLI instead of looking for this package? I have added this to my PATH and it still doesn't work. Any ideas? Other Strongloop commands, like sl-build work and strongloop is listed in npm list -g . 回答1: Ubuntu 14 with

Strongloop with Emberjs

依然范特西╮ 提交于 2019-12-23 09:27:02
问题 Ember Data's REST Adapter accepts the JSON from the server in this format: Taken from the documentation: http://guides.emberjs.com/v1.10.0/models/the-rest-adapter/ { "post": { "id": 1, "title": "Node is not omakase", "comments": [1, 2, 3] }, "comments": [{ "id": 1, "body": "But is it _lightweight_ omakase?" }, { "id": 2, "body": "I for one welcome our new omakase overlords" }, { "id": 3, "body": "Put me on the fast track to a delicious dinner" }] } Is it possible to have this kind of JSON

How to create data view models in Loopback?

雨燕双飞 提交于 2019-12-23 06:05:01
问题 Basically what the title asks. I'm wondering if it's possible to create a a custom view model in Loopback that is datasource ignorant? My current process has been to create a view in MySQL, and then build a model in Loopback that overlays the view, but I recently realized that if we decide to migrate to a different back end, or change the datasource somehow, we'd have to figure out how to recreate the view. Google searches on this have revealed bupkis, so I figured I'd throw it out here to

How to create data view models in Loopback?

心已入冬 提交于 2019-12-23 06:04:09
问题 Basically what the title asks. I'm wondering if it's possible to create a a custom view model in Loopback that is datasource ignorant? My current process has been to create a view in MySQL, and then build a model in Loopback that overlays the view, but I recently realized that if we decide to migrate to a different back end, or change the datasource somehow, we'd have to figure out how to recreate the view. Google searches on this have revealed bupkis, so I figured I'd throw it out here to

Npm errors while I try to install dependencies in loopback (strongloop) webapp

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 01:22:32
问题 I am new in the NodeJS world. I have created an loopback(strongloop) webapp, but after it I try to run the npm install command in the application's folder I get this output in the terminal (Ubuntu server 14.04 withd newest updates - in a vagrant instance) vagrant@vagrant-ubuntu-trusty-64:/vagrant/example-app$ npm install npm WARN package.json example-app@1.0.0 No license field. npm WARN optional dep failed, continuing ycssmin@1.0.1 npm WARN deprecated jsonstream@1.0.3: use JSONStream instead

How to set up ACLs to allow users to access only specific records?

 ̄綄美尐妖づ 提交于 2019-12-22 21:56:34
问题 I'm planning to use Loopback to create an application where users will be able to access only specific records. Let's say we have a Projects model, with 2 records: { "projects": [ { "project_name": "foo", "project_start_date": "2012-10-29T18:25:43.511Z" }, { "project_name": "bar", "project_start_date": "2012-10-30T18:25:43.511Z" } ] } and that I have 2 users, joe and katie . I want joe to be able to access only project foo , and katie to be able to access only project bar . Is this possible