strongloop

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

hasMany relation: including from the other direction

天涯浪子 提交于 2019-12-08 02:55:41
问题 Say I have the next model: user.json: {//... "relations":{ "invoices": { "type": "hasMany", "model": "Invoice", "foreignKey": "receiverId" }, } //... } A.k.a. a user might have many invoices. This code adds the field receiverId to the invoice model. Now I want to get a list of invoices including their receivers. How can I do that? Invoice.find({include: "reciever"}) Or Invoice.find({include: "user"}) Did not work, returned: "Relation \"receiver\" is not defined for Invoice model" error.

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

How do I use a remote method in one model to return info from another model?

瘦欲@ 提交于 2019-12-07 19:05:00
问题 So I've set up something really simple to learn how to use Loopback. The models are as follows: Person - based on built in User model food_pref typeId (number) personId (number) food_type type (string) Relationships: Person has many food_prefs (foreign key: personId) food_pref belongs to Person (foreign key: personId) food_pref belongs to food_type (foreign key: typeId) An auto-generated method gets created that returns the food_prefs based on the id of the Person. People/{id}/foodPrefs This

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

How can I update hasandbelongstomany relations for multiple models at once in strongloop loopback

断了今生、忘了曾经 提交于 2019-12-07 15:22:22
问题 I have 2 models in a Strongloop Loopback API Products Tags Between those 2 models I have defined a hasAndBelongsToMany-relation . In my CMS I want a bulk-update functionality for my products, in which I can select many Products, and assign many tags, in one action. How can I save those easily to my Mysql-DB, without having to iterate over each product, then iterate over each tag, and link those 2 ? I checked in the docs and found the add and remove functions, but those only connect one model

Reset Loopback Password with Access Token

泪湿孤枕 提交于 2019-12-07 11:28:29
问题 I'm working on a project that uses Loopback as a framework, and includes users and authentication. I added a password reset route generated and sent in an email, and everything seemed to be working correctly. Recently, I discovered that the password reset does not appear to be working. The process for resetting the password here is: Call password reset method for user Send email from reset event, including user ID and access token From reset link, set $http.defaults.headers.common

Loopback 2.4: how to query certain fields of related model via REST API

家住魔仙堡 提交于 2019-12-07 04:03:53
问题 I have User model over relational DB. Each User can hasMany "users" where "chiefId" is FK. "relations": { "users": { "type": "hasMany", "model": "User", "foreignKey": "chiefId" }, } I can query related users for each chief-user like this: GET /users?filter={"include":"users"} But it returns full user objects. How should I query only "name" properties of related users? Also is it possible to count related instances in one request to server? 回答1: A late reply but I just ran into this question

Querying from models with HasManyThrough relations - strongloop api

佐手、 提交于 2019-12-06 16:37:36
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_bridge . I followed the guidelines to set HasManyThrough relations . The issue is that the additional