loopbackjs

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');

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 - findById requires the id argument

回眸只為那壹抹淺笑 提交于 2020-01-07 03:11:09
问题 I am new to loopback and I am trying to create a simple remote method in loopback that uses findyById method. Been spending couple of hours on this and still can't get it to work. Here is my code: customer.js: Customer.list = function(customerId, cb){ app.models.Customer.findById(customerId, function (err, instance) { cb(null, err || 'success'); if(err){ console.log(err); }else if(instance){ console.log(instance); } }); } // expose the above method through the REST Customer.remoteMethod('list

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 =

API Server returns a 404 Error

女生的网名这么多〃 提交于 2020-01-05 19:38:40
问题 I have created an AngularJS webapp that uses node, loopback, ui-router, and bootstrap. I am building my app using Brackets and when I launch their live preview (http://127.0.0.1:53490/index.html). The page loads all elements but does not populate the proper database information. I know that the loopback api and mysql database connection works because I can push and pull data from the table in the loopback explorer. The issue seems to be in the connection between my webapp and loopback. The

Tags relationship in loopback 3

心已入冬 提交于 2020-01-05 05:32:09
问题 In Loopback how can I create tags? For example there are projects { id, name } and there are tags collection with the similar model Now the project needs to have multiple tags, and the same tag can be used in multiple projects. For example while creating a project, the user may type already existing tags, or new tags, and those should be added to the project. I can't find the exact relationship I need in the loopback framework. How do you do that? 回答1: TLDR CREATE TABLE ProjectTag (id AUTO

How to make Loopback models events work?

大憨熊 提交于 2020-01-04 13:48:09
问题 I have tried an example from http://apidocs.strongloop.com/loopback/#model: MyModel.on('changed', function(inst) { console.log('model with id %s has been changed', inst.id); // => model with id 1 has been changed }); I replaced MyModel with actual model name. When I save a new instance or update an existing one, I expect to see a console log, but nothing happens. How do I make it work as it's described in the docs? 回答1: As I am using Loopback 3.0, not 2.0, the mentioned listener is deprecated

How to make Loopback models events work?

点点圈 提交于 2020-01-04 13:47:15
问题 I have tried an example from http://apidocs.strongloop.com/loopback/#model: MyModel.on('changed', function(inst) { console.log('model with id %s has been changed', inst.id); // => model with id 1 has been changed }); I replaced MyModel with actual model name. When I save a new instance or update an existing one, I expect to see a console log, but nothing happens. How do I make it work as it's described in the docs? 回答1: As I am using Loopback 3.0, not 2.0, the mentioned listener is deprecated