loopbackjs

Auto-create mysql table with StrongLoop

怎甘沉沦 提交于 2019-12-09 05:14:33
问题 I am trying to use Strongloop with MySql but cannot figure out how to migrate or automatically create tables into a MySql database. Is there at least a way to export the models into MySql schemas or do I have to manually create the tables? I've been trying with the mysql demo app, and going over the docs for a while but no luck - http://docs.strongloop.com/display/DOC/MySQL+connector Thanks! 回答1: LoopBack calls it auto-migration. Check these links and search for that term: Recipes for

Level 2 (related model) scope over REST - strongloop api

本秂侑毒 提交于 2019-12-09 01:24:47
问题 I found in the documentation that scopes enable you to specify commonly-used queries that you can reference as method calls on a model. Below i have a categories model. I am trying to create scopes that applies to the relation with model games . Unfortunately the below does nothing. How can I get scopes to apply to relation as shown below? GET /Categories/{id}/games - This gets all games common/models/category.json "relations": { "categories": { "type": "hasMany", "model": "game", "foreignKey

StrongLoop Loopback : How to customize HTTP response code and header

北慕城南 提交于 2019-12-08 19:06:50
问题 I'm looking for a way to customize StrongLoop LoopBack HTTP response code and headers. I would like to conform to some company business rules regarding REST API. Typical case is, for a model described in JSON, to have HTTP to respond to POST request with a code 201 + header Content-Location (instead of loopback's default response code 200 without Content-Location header). Is it possible to do that using LoopBack ? 回答1: Unfortunately the way to do this is a little difficult because LoopBack

loopback - Upload files from another model

强颜欢笑 提交于 2019-12-08 13:09:10
问题 I have two models: container : handles file uploading and works fine in loopback explorer. Crawler : have multiple properties. one of the properties is script that user can upload a script file to this model. crawler.json : { "name": "Crawler", "base": "PersistedModel", "idInjection": true, "options": { "validateUpsert": true }, "properties": { "name": { "type": "string", "required": true }, "script": { "type": "string" }, "startCount": { "type": "number", "default": 0 }, "created_at": {

Permanent token on loopback

我怕爱的太早我们不能终老 提交于 2019-12-08 05:26:55
问题 I am building an app using Loopback API that will be consumed by an iPhone APP. There is a connection to a MySQL database where I run some queries to get some results and expose on the API. The endpoints contain an ACL that will allow only authenticated users to perform any operation, including the GET ones. So basically the requests need to be done using the ?access_token query string. I want to set a token that can be saved on the MySQL database and can be used "forever" on the API. I am

Querying from models with HasManyThrough relations - strongloop api

前提是你 提交于 2019-12-08 03:17:03
问题 This is a follow up to a previous question. Currently, the api can query from the category and game model which share a relation. For example, through this endpoint /Categories/1001/games/mature I can list all games of fighting category that have mature set to true . However, I have included a third model gameInfo from db table game_info . Since, I want to fetch the information from those three tables, i have included a through model named gamesCategoriesBridge from db table games_categories

Allow loopback application to use previous access token

倾然丶 夕夏残阳落幕 提交于 2019-12-07 20:16:59
问题 In my loopback application, once i create the access token (after login), it remains valid in my application unless application stops. when application restarted it is not allowing previous access token. How can i make previous access token validate even after restarting the application? 回答1: Your access token is getting stored by default in loopback memory . Therefore, it persists only until the application is restarted. open server/model-config.json "AccessToken": { "dataSource": "db",

How can I hide the 'id' attribute in Loopback explorer?

≡放荡痞女 提交于 2019-12-07 19:18:14
问题 Is it possible to hide the id attribute in a method in swagger-ui generated by explorer in Strongloop Loopback? I don want the user to create a new resource and send the id attribute. I know that if the user send the id it can be ignored but I want to hide it in the explorer. 回答1: In order to hide the 'id' attribute, you need declare this field as hidden. In YOUR_MODEL.json file: { "name": "YOUR_MODEL", . . . "properties": { // your custom properties }, "hidden": ["id"], // this attribute

Loopback authorize a user to see only his data

点点圈 提交于 2019-12-07 18:37:08
问题 I am developing a NodeJS application using Loopback. I am pretty new to both nodejs and REST APIs, so please correct me if I am conceptually wrong. Loopback automatically builds CRUD REST APIs, which is a feature I would like to use in order to avoid to write APIs by myself, but I need to limit users to be able to see only their data. For example, imagine there are 3 tables in my DB, user , book and a relation table user_book . So for example: table user id | name --------- 1 | user1 2 |

Loopback - Implementing custom authentication

北城以北 提交于 2019-12-07 17:48:31
问题 We are developing a REST service but we already have an infrastructure in place to manage users. But we want to leverage the authentication and authorization mechanism of Loopback. The requirement is to Add a remote method and receive the user credentials Manually verify the credentials through stored procedure call Generate the access token through Loopback Going forward use Loopback authorization mechanisms such as roles in the application Should I be implementing a custom login service