loopbackjs

How to override base User in a Strongloop loopback scaffolded project?

我是研究僧i 提交于 2019-12-03 17:23:19
Given a brand new project created with: $ slc lb project myapp How do I replace the ' user ' model in models.json with a ' customer ' model placed in the ./models directory? Customers should have the login/logout etc. methods and 'users' should not exist as an API. Also, the customer model should not be dynamic. Let's pretend customer should have a schema as follows: name email password question answer phone verified dataCreated I've been playing with this for a couple of days and my google-fu is letting me down. Any help appreciated. Thanks. This is the idiomatic way: In models.json , rename

How to query models by a property that is an array

这一生的挚爱 提交于 2019-12-03 17:16:15
I'm trying to do a 'findOne' operation in a model that has an array property and filter the results to only list the item if the string im searching is in that array. Example: var AppUser = server.loopback.getModel('AppUser'); AppUser.create({ "name":"juan" "favoriteLetters":["a","b","c"] },function(){ AppUser.findOne({where:{favoriteLetters:'a'}},function(error,appUser){ console.log(error,appUser); }); }); So in this case i want to find a 'appUser' that has a favorite letter 'a'. Thanks. As far as I understood, possibility of such kind of a query depends on the underlying datasource and is

How to configure StrongLoop LoopBack MongoDB datasource for deployment to Heroku

混江龙づ霸主 提交于 2019-12-03 13:32:33
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'); var mongoUri = process.env.MONGOLAB_URI || process.env.MONGOHQ_URL || 'mongodb://localhost/mydb'; mongo

Diacritic Case-Insensitive search Loopback

前提是你 提交于 2019-12-03 12:24:18
Is there any way to query results on Loopback+MongoDB with Diacritic-Case-Insensitive options? For example, If I want to search for the query olimpic , and the database contains words like: Olímpic olimpic Olimpic Then, all of the above should be returned as results. I have tried with multiple queries listed below and other combinations, but nothing has worked so far. {"where":{"name.text":{"like":"olimpic","options":"i"}}} {"where":{"name.text":{"like":"/^olimpic$/i","options":"i"}}} {"where":{"name.text":{"like":"/.*olimpic.*/i"}}} {"where":{"name.text":{"regexp":"/.*olimpic.*/i"}}} Any idea

Login by facebook in angular app with loopback backend

这一生的挚爱 提交于 2019-12-03 12:11:01
问题 I'm making an angular application with strongloop loopback backend. Also I integrating a third party login by facebook using loopback-passport module. everything was fine in loopback-example-passport and everything is fine in my app right before the moment of redirecting to my app. User and Access-token created. the code: app.get('/auth/login', ensureLoggedIn('/#login'), function(req, res, next) { console.log('LOOGED IN!!'); console.log(req.user); res.redirect('/#auth/login'); }); works fine.

Ensure unique field value in loopback model

杀马特。学长 韩版系。学妹 提交于 2019-12-03 07:01:33
问题 How to ensure uniqueness of a particular field in loopback model. Like below is the model Post, I have a field genericId in it, I want it to be unique in the database, and loopback to through an error, on duplicate key insertion. { "name": "Post", "plural": "Post", "base": "PersistedModel", "properties": { "genericId": { "type": "string", "required":True }, "moderatedAt": { "type": "date" } }, "validations": [], "acls": [], "methods": [] } I have tried searching there documentation, and other

Auto-create mysql table with StrongLoop

六月ゝ 毕业季﹏ 提交于 2019-12-03 05:30:18
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! user3259256 LoopBack calls it auto-migration. Check these links and search for that term: Recipes for LoopBack Models, part 5 of 5: Model Synchronization with Relational Databases Data sources and

Loopback passport mobile login

ⅰ亾dé卋堺 提交于 2019-12-03 03:55:05
问题 I'm developing an API with loopback and passport. I've seen this example, which is quite good: https://github.com/strongloop/loopback-example-passport In the documentation, they say loopback follows this step to authenticate users via third party providers: A visitor requests to log in using Facebook by clicking on a link or button backed by LoopBack to initiate oAuth 2.0 authorization. LoopBack redirects the browser to Facebook's authorization endpoint so the user can log into Facebook and

Loopback discoverAndBuildModels not generating models

前提是你 提交于 2019-12-03 03:34:07
I'm trying to get Loopback to discover and build my first table. I've used the simple example on their page at the bottom here: http://docs.strongloop.com/display/LB/Database+discovery+API#DatabasediscoveryAPI-Exampleofbuildingmodelsviadiscovery and I see the output of the table I'm discovering, but the API Explorer doesn't show the table or any newly generated endpoints. Also, the model-config.js file is not updated with the new table object. Here is the basic section of the code done on server start: var loopback = require('loopback'); var boot = require('loopback-boot'); var DataSource =

Login by facebook in angular app with loopback backend

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 02:37:09
I'm making an angular application with strongloop loopback backend. Also I integrating a third party login by facebook using loopback-passport module. everything was fine in loopback-example-passport and everything is fine in my app right before the moment of redirecting to my app. User and Access-token created. the code: app.get('/auth/login', ensureLoggedIn('/#login'), function(req, res, next) { console.log('LOOGED IN!!'); console.log(req.user); res.redirect('/#auth/login'); }); works fine. But i can't understand. how to give authenticated state to my angular application. i tried to make a