strongloop

Strongloop: filter data with [and] and [or] conditions together

那年仲夏 提交于 2021-02-19 06:00:35
问题 I'm trying to filter data using "and" and "or" conditions. I would like to get this mySql query: SELECT * FROM `data` WHERE ((`property1`=11) OR (`property1`=13)) AND (`property2`=6) The rest api that I wrote is like this: http://localhost:4000/api/Data/?filter[where][or][0][property1]=11&filter[where][or][1][property1]=13&filter[where][and][0][property2]=6 The loopback json translation seems to be correct: { "or": [ { "property1": 11 }, { "property1": 13 } ], "and": [ { "property2": 6 } ] }

strongloop/loopback - Change connection string based on route value

梦想的初衷 提交于 2020-06-28 04:17:09
问题 My application's users are geographically dispersed and data is stored in various regions. Each region has it's own data center and database server. I would like to include a route value to indicate the region that the user wants to access and connect to, as follows: /api/region/1/locations/ /api/region/2/locations/ /api/region/3/locations/ Depending on the region passed in, I would like to change the connection string being used. I assume this can be performed somewhere in the middleware

loopback 4 hasMany include filter Error 500

纵饮孤独 提交于 2020-03-23 04:14:09
问题 i am doing some practice with loopback 4, following the tutorial todo-list https://loopback.io/doc/en/lb4/todo-list-tutorial.html i am trying to query data to gel todo-lists and related todos GET http://127.0.0.1:3000/todo-lists?filter[include]=todos i get an error 500 : relations "todos" not defined for the model TodoList The route GET http://localhost:3000/todo-lists/1/todos works properly, but i'd like to retrieve lists and related todos. I read many posts and the documentation but i do

The best solution for control access to models in strongLoop

别来无恙 提交于 2020-02-29 06:11:54
问题 I'm new in StrongLoop. I have 2 models( CustomUser and Item ). I want any CustomUser has access to his Items . I don't want use default APIs exposed by StrongLoop because i don't want CustomUsers able to define filter with these APIs. I define my RemoteMethod that returns items based on a internal filter. My question: Should i check current user and return his related items or can i use ACL in StrongLoop for this matter? If the ACL is correct answer, where should i insert my RemoteMethod(

The best solution for control access to models in strongLoop

爷,独闯天下 提交于 2020-02-29 06:11:25
问题 I'm new in StrongLoop. I have 2 models( CustomUser and Item ). I want any CustomUser has access to his Items . I don't want use default APIs exposed by StrongLoop because i don't want CustomUsers able to define filter with these APIs. I define my RemoteMethod that returns items based on a internal filter. My question: Should i check current user and return his related items or can i use ACL in StrongLoop for this matter? If the ACL is correct answer, where should i insert my RemoteMethod(

Strongloop : Compare old model with the new instance in operation hook 'before save'

泪湿孤枕 提交于 2020-01-16 18:33:34
问题 I implemented a "before save" operation hook in my code to compare the new instance about to be saved with the old one already in the database. For that, I compare the value given in the ctx.data with the one given by a query in the database. The problem is the returned values are always similar, as if the new instance has already been saved in the database. Have I totally missed the point of the "before save" hook, or is there a way to compare the two values ? module.exports = function(app)

loopback.io model, acl principalId, $owner

做~自己de王妃 提交于 2020-01-15 11:48:09
问题 I need to limit data access in a model only to the loopback user that created it. I saw this in the docs: http://loopback.io/doc/en/lb2/Model-definition-JSON-file.html#acls $owner - Owner of the object Does that mean the logged in user who created that object? When a model runs create, is loopback.io storing the user id of the current logged in user inside it's own ACL? Or will I need to do something like this, which is to create new properties on my model with relations to the user model:

Loopback push array

故事扮演 提交于 2020-01-14 06:51:11
问题 How would I go about making a custom remoteMethod that updates/pushes, not overrides , a property that is an array . So basically push data to an array property of a model. I can't find any clear examples of this in the documentation, except for an .add() helper method, but that requires an embedsOne or some other relation. But what if I have a single Model in my whole app and would just want to push some data to an id . So ending up with an endpoint like: POST /Thing/{id}/pushData And the

Loopback hasMany relation doesn't work on mongodb

时光总嘲笑我的痴心妄想 提交于 2020-01-14 03:36:26
问题 I have some strange behavior after moving from RedHat linux to SUSE on AWS. Everything was working fine, before. Here is my relations: Category: { "name": "Category", "plural": "categories", "base": "PersistedModel", "relations": { ... "professions": { "type": "hasMany", "model": "Profession", "foreignKey": "" } } } Profession: { "name": "Profession", "plural": "professions", "base": "PersistedModel", "relations": { ... "category": { "type": "belongsTo", "model": "Category", "foreignKey": ""

How to configure StrongLoop LoopBack MongoDB datasource for deployment to Heroku

强颜欢笑 提交于 2020-01-12 07:37:07
问题 I'm using LoopBack ver. 1.6 and have a local mongoDB server running for development using he following datasource configuration: "mongodb": { "defaultForType": "mongodb", "connector": "loopback-connector-mongodb", "database": "xxxdbname", "host": "localhost", "port": "27017" }, Now I want to deploy to Heroku but I don't know how to configure the datasource to point at the MongoLab db since it has a dynamically generated connection string: from the Heroku dox: var mongo = require('mongodb');