loopbackjs

Making Loopback API Ember.js compatible

家住魔仙堡 提交于 2019-12-12 10:46:43
问题 I'm trying out Loopback for an API that will talk to Ember. Ember requires JSON to be contained in 'keys', e.g. for an account: { account: { domain: 'domain.com', subdomain: 'test', title: 'test.domain.com', id: 1 } } I've found some advice on the Google group about how to alter the response so that Ember will receive it, using afterRemote hooks. E.g. in my models/account.js: module.exports = function(Account) { Account.afterRemote('**', function (ctx, account, next) { if(ctx.result) { if

loopback: logging queries executed by datasource

非 Y 不嫁゛ 提交于 2019-12-12 10:18:24
问题 Is there a remote method in Loopback data-juggler or any other loopback component which will let me log the query that is executed by the datasource. Eg: If i'm using MySQL connector, then when MODEL_NAME.findById() is called, i should be able to get SELECT * from DATABASE_NAME.MODEL_TABLE where id = WHATEVER_ID Similarly for MongoDB, it should return equivalent mongo query It'd be great if i am able to log query.explain() of mongo here itself I've tried running my app as DEBUG=loopback

How to use TypeScript with Loopback

≯℡__Kan透↙ 提交于 2019-12-12 08:33:46
问题 I'm using Loopback from Strongloop as a REST framework and ORM. I want to use TypeScript for my business logic. However, Loopback requires JavaScript with a specific shape to support their framework. For example: module.exports = function(Person){ Person.greet = function(msg, cb) { cb(null, 'Greetings... ' + msg); } Person.remoteMethod( 'greet', { accepts: {arg: 'msg', type: 'string'}, returns: {arg: 'greeting', type: 'string'} } ); }; What is the TypeScript code that will generate the above

Creating Permanent AccessToken in loopback

蓝咒 提交于 2019-12-12 07:14:24
问题 How to create a permanent access token for a StrongLoop API. Now for every user login it creates an access token. And unnecessary entry in my db I can increase the validity of access token(ttl) as mentioned here. But still it will generate for new login. 回答1: You are mixing up 2 different things. The AccessToken entry creation and the ttl value for the AccessToken. When a user logs in a new AccessToken is created. If the user logs out the AccessToken is removed. If the user logs in 2 times,

strongloop loopback: how to add remote method to loopback-component-storage Container

妖精的绣舞 提交于 2019-12-12 06:10:21
问题 I'm trying to add a new REST API method to the loopback-component-storage for downloading all photos from a Container. (see Strongloop loopback-storage-service: how to use StorageService.downloadStream() to download a ZIP of all photos in container?) The following code seems to work, but I'd like to know how to load the storage-handler, handler , and filesystem provider, factory , correctly within the strongloop framework. Also, I shouldn't have to copy the data in datasources.json Any

Set the custom properties in joining model using LoopBacks HasManyThrough

情到浓时终转凉″ 提交于 2019-12-12 05:39:46
问题 I am trying to set up a many to many relationship in LoopBack 2.1.2 http://docs.strongloop.com/display/LB/HasManyThrough+relations I tried to POST /api/patients/:patientId/physicians to create a new physician which links the patientId to the new physician, but does not set the appointmentDate in the appointment model. Is there one API call to create this in one transaction? What is the best way to add a new physician to a patient and setting the appointmentDate? Do I have to create my own

Strongloop loopback-storage-service: how to use StorageService.downloadStream() to download a ZIP of all photos in container?

别等时光非礼了梦想. 提交于 2019-12-12 04:57:04
问题 I'm using loopback-component-storage with the filesystem provider to upload photos. It works great. But now I have a request to 'export/download' photos to a zip archive. I've put together some code to add another method, downloadContainer() to Container from the file-storage example. It uses the Archiver module, everything seems to work fine, but the browser crashes after I call zip.finalize() I'm expecting to get a save file dialog box instead... Here is my code so far: Container

Multiple includes on different depths in a LoopBack/Node.js query

妖精的绣舞 提交于 2019-12-12 04:40:27
问题 I'm trying to load an object on a node.js Loopback server and I want to load multiple related objects in the same query. These related objects are on different depths. This is the query: /api/MyUsers/114?filter[include][institutes]=institute&filter[include]=departments&filter[include]=profiles Notice that [institutes]=institute have two levels and departments and profiles only one. This returns me an error: 500 Internal server error. Error: Relation "0" is not defined for User model. On node

How to specify Strongloop model schema?

怎甘沉沦 提交于 2019-12-12 04:18:33
问题 I try override find api of strongloop rest endpoint. I want to return an array of objects. But how do I specify the schema for the object? As you can see from the picture above, the model schema is empty. Below is the code of my company model remoteMethod: Company.remoteMethod( 'find', { accepts: {arg: 'msg', type: 'string'}, returns: {type: 'array', root: true}, http: {path: '/', verb:'get'} } ) 回答1: If I understand you right, your'e trying to show at this section the returned model as

Strongloop How to config mysql timezone?

橙三吉。 提交于 2019-12-12 02:23:18
问题 I'm a greenhand for strongloop. My datasources.json config is as follows: "platformDB": { "host": "localhost", "port": 3306, "database": "way", "username": "root", "password": "root", "name": "platformDB", "connector": "mysql" }, and UserAccount is my one model as follows: "name": "UserAccount", "plural": "user", "base": "PersistedModel", "idInjection": true, "properties": { "id": { "type": "number", "required": false }, "accountName": { "type": "string", "required": false }, "roleName": {