loopbackjs

loopback automigrate vs autoupdate

纵然是瞬间 提交于 2019-12-10 16:21:06
问题 When we have model and we want to migrate it to database, we simply create script in server/boot with: server.dataSource['myDbSource'].automigrate('MyMode', function(err){...}) or server.dataSource['myDbSource'].autoupdate('MyMode', function(err){...}) First one on each server restart, recreate schema in db and clear data, second one can create schema or change it if exist, but not clear data. When we used automigrate to create schema we should remove it (or each time our data will be lost),

Difference between swagger and loopback for Rest API

旧时模样 提交于 2019-12-10 12:37:30
问题 Swagger helps in creating Restful Api, I get that. Where would you use LoopBack, is this another tool for creating Rest api. LoopBack has support swagger 2.0. I am confused here, can they be used interchangeably. 回答1: Swagger is a documentation framework. If you attach the appropriate annotations to your code, it produces a "live" documentation site that lets users see all your REST services in a visual way, including their request and response formats, with the ability to execute sample

Rename file before upload using remote hooks in loopback component storage

大憨熊 提交于 2019-12-10 11:57:42
问题 I am having difficulty in renaming a file before upload in loopback component storage. As it seems, loopback does'nt provide a built-in option for the same. For uploading from a angular form, I have used the angular uploader beforeupload method to change the filename using following method: this.fileExtension = '.' + item.file.name.split('.').pop(); item.file.name = Math.random().toString(36).substring(7) + new Date().getTime() + this.fileExtension; Is it possible to perform the same

Customizing User built-in Model validation

女生的网名这么多〃 提交于 2019-12-10 11:54:20
问题 I'm looking for a way to customize the validation for the built-in User Model. The objective is to be allow users to register an account with the same e-mail but different username. I've tried to override the Setup Method for the User Model to prevent the validation of the uniqueness of the email property, but unfortunately that was a no go. As for hooks, I've couldn't find any to fulfill my needs. For reference, the validation occurs in 'loopback/common/models/user.js:556': if (!(UserModel

ACL troubles with loopback.io

≯℡__Kan透↙ 提交于 2019-12-10 11:04:24
问题 I'm currently evaluating loopback.io for developing the API portion of a new project, and I'm having problems with setting the correct ACL entries. What I wish to accomplish is given an auth token, the GET endpoints should only return objects owned by the user. For example, a request to /Shows?access_token=xxxxxx should return only objects owned by the user. Below is my shows.json file, and my User model is named Podcaster. Any help would be appreciated. { "name": "Show", "base":

LoopBack: How to Dynamically Create Custom REST Endpoints In Code (On The Fly)

你离开我真会死。 提交于 2019-12-10 10:55:18
问题 We are using the LoopBack REST framework to expose our database (and business logic). We need to allow our customers to create custom tables in the database (single and multi-tenant) which can be accessed via a REST endpoint. All customers need to use the same common (production) REST endpoints which will be on exposed on multiple servers. However, custom tables and associated REST endpoints need to be accessible to only the customers that created them. Which means we cannot write the model

How to set up the ACL to allow everyone list all the Users from the REST API

妖精的绣舞 提交于 2019-12-10 01:50:07
问题 Im trying to list all the Users in my loopback 2.0 app using the REST API and I'm getting the following error: { "error": { "name": "Error", "status": 401, "message": "Authorization Required", "statusCode": 401, "stack": "...." } } I manually added the ACL to the model-config.json file: "User": { "dataSource": "db", "acls": [ { "principalType": "ROLE", "principalId": "$everyone", "permission": "ALLOW", "accessType": "*" } ] }, Since that failed, I created a model based on the User built-in

Diacritic Case-Insensitive search Loopback

China☆狼群 提交于 2019-12-09 09:37:44
问题 Is there any way to query results on Loopback+MongoDB with Diacritic-Case-Insensitive options? For example, If I want to search for the query olimpic , and the database contains words like: Olímpic olimpic Olimpic Then, all of the above should be returned as results. I have tried with multiple queries listed below and other combinations, but nothing has worked so far. {"where":{"name.text":{"like":"olimpic","options":"i"}}} {"where":{"name.text":{"like":"/^olimpic$/i","options":"i"}}} {"where

Dynamically adding user to a loopback Role

拥有回忆 提交于 2019-12-09 07:14:25
问题 I have been studying the loopback / Strongloop documentation and it is not clear to me that it is possible to dynamically add a new user to a role (i.e. add a user to role via role-mapping), that is, without the need to restart the API. Can anyone confirm one way or the other? (ideally, but not necessarily, pointing me to some documentation or example to confirm or not that this is doable). Thanks much. 回答1: You can create rolemappings for users in strongloop with something like this - Role

StrongLoop Loopback example in Swift

限于喜欢 提交于 2019-12-09 06:22:08
问题 I'm trying to implement the example LoopBack iOS app in Swift Create a LoopBack iOS app: part one and I'm having some trouble translating from the ObjectiveC - (void) getBooks { //Error Block void (^loadErrorBlock)(NSError *) = ^(NSError *error){ NSLog(@"Error on load %@", error.description); }; void (^loadSuccessBlock)(NSArray *) = ^(NSArray *models){ NSLog(@"Success count %d", models.count); self.tableData = models; [self.myTable reloadData]; }; //This line gets the Loopback model "book"