strongloop

LoopbackJS: HasAndBelongsToMany, how to query/filter by property of relation?

情到浓时终转凉″ 提交于 2020-01-10 05:27:26
问题 I'm currently working on my first Loopbackjs project and am facing a seemingly simple issue: Let's say I have a model "Post" and a model "Tag". A Post has and belongs to many tags. Now I need to list all posts with specific tags. I just can't figure out how to create a query with Loopback that achieves this. I thought it would work something like this, but it doesn't: Posts.find( {where: {tag.id: {inq: [1, 4]}}} ); I would greatly appreciate any help. 回答1: It's not as easy as it should be to

LoopbackJS / AngularJS find with relation hasOne include separated attribute

三世轮回 提交于 2020-01-06 19:38:12
问题 i'm making a find query in angularjs using loopbackapi , in mysql db. I have a model with a hasOne relation with another one. Empresa hasOne Operadora When i do a find in Empresa using include args, it brings me Operadora attributes, but it include the attributes inside Empresa, but i would like to have it separated. I tested using those examples: Empresa.findOne({ include: {"relation" : 'Operadora', 'as': 'Operadora'} Empresa.findOne({ include: {model: 'Operadora', 'as': 'Operadora'} Empresa

Loopback send Email with attachment from another module

断了今生、忘了曾经 提交于 2020-01-06 05:56:13
问题 I have form where i can able to save the file in some location and can store the values in the database.Now i have the email connector where i can fetch the values of the form and send it through email. I have two models one is for storing the values in the database i.e PersistedModel and the other is for storing the attachment now i want to send an email with attachment. how to send can anyone help me. career.js 'use strict'; const app = require('../../server/server'); module.exports =

Generate new verification token

爱⌒轻易说出口 提交于 2020-01-05 05:00:15
问题 I'm would like to know how could i create a method, or if there is a method to generate a new token only with the email. I want create a option in my site "Send new verification email", where the user only needs to put the email. Actually i'm using Mandril, so i'm using a custom way to send emails and verify users: function generateVerificationToken(context, user, callback) { const { req } = context; req.app.models.User.generateVerificationToken(user, (error, token) => { if (error) { return

Why Principal is not a model, but Role, RoleMapping, ACL are suddenly models?

可紊 提交于 2020-01-02 06:43:49
问题 I'm reading Access control concepts of Loopback (https://docs.strongloop.com/display/public/LB/Authentication%2C+authorization%2C+and+permissions) and I don't understand how happened that Principal is not a model, but Role , RoleMapping , ACL are models with a full set of REST API methods and are listed in model-config.json ? When I tried to include Principal in model-config.json along with Role , RoleMapping and ACL I got error: "ACL": { "dataSource": "db", "public": false }, "RoleMapping":

Why Principal is not a model, but Role, RoleMapping, ACL are suddenly models?

拜拜、爱过 提交于 2020-01-02 06:43:05
问题 I'm reading Access control concepts of Loopback (https://docs.strongloop.com/display/public/LB/Authentication%2C+authorization%2C+and+permissions) and I don't understand how happened that Principal is not a model, but Role , RoleMapping , ACL are models with a full set of REST API methods and are listed in model-config.json ? When I tried to include Principal in model-config.json along with Role , RoleMapping and ACL I got error: "ACL": { "dataSource": "db", "public": false }, "RoleMapping":

How integrate loopback third-party login for android

﹥>﹥吖頭↗ 提交于 2020-01-01 09:18:35
问题 My project includes web and android client. I want to combine Google cross platform sign-in and loopback third-party login. In my scenario, I will never ask username and password. User only uses Google sign-in button for authentication and authorization on both web and android app. Lets assume, it's the first time you logged in with Google sign-in through my web site. In loopback third-party scenario, if you are not existing on db, it creates an account corresponded provider and external id.

loopbackjs: Attach a model to different datasources

旧巷老猫 提交于 2019-12-30 04:33:05
问题 I have defined several models that use a Datasource "db" (mysql) for my environment. Is there any way to have several datasources attached to those models, so I would be able to perform REST operations to different databases? i.e: GET /api/Things?ds="db" GET /api/Things?ds="anotherdb" GET /api/Things (will use default ds) 回答1: As @superkhau pointed above, each LoopBack Model can be attached to a single data-source only. You can create (subclass) a new model for each datasource you want to use

How do you import a user model with strongloop arc database discovery

孤街醉人 提交于 2019-12-25 04:38:21
问题 The loopback application already comes equipped with a user model and CRUDs; however, I'm trying to hook an old database up to my loopback application that already contains a user model so the model discovery replies with: ValidationError: The `ModelDefinition` instance is not valid. Details: `name` is not unique (value: "User"). at /home/theory/.nvm/versions/v0.12.4/lib/node_modules/strongloop/node_modules/loopback-datasource-juggler/lib/dao.js:264:12 at ModelConstructor.<anonymous> (/home

StrongLoop overriding PUT built in method

你说的曾经没有我的故事 提交于 2019-12-25 04:22:12
问题 I am facing an issue trying to override StrongLoop built in method for PUT request. So in model.js file I am using: Model.on('attached', function(){ Model.updateAttributes = function(data, id, cb){ cb(null,'This is a overridden method'); }; } But when I call the endpoint with a PUT /api/v1/models/1 and payload this function does not get executed but the built in one. I also tried to use other function instead of updateAttributes but without any success like for example: Model.updateAll =