strongloop

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

五迷三道 提交于 2019-12-05 01:46:22
问题 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

How to set up the ACL to allow everyone list all the Users from the REST API

孤者浪人 提交于 2019-12-05 01:16:13
Im trying to list all the Users in my loopback 2.0 app using the REST API and I'm getting the following error: { "error": { "name": "Error", "status": 401, "message": "Authorization Required", "statusCode": 401, "stack": "...." } } I manually added the ACL to the model-config.json file: "User": { "dataSource": "db", "acls": [ { "principalType": "ROLE", "principalId": "$everyone", "permission": "ALLOW", "accessType": "*" } ] }, Since that failed, I created a model based on the User built-in model: { "name": "Admin", "base": "User", "properties": {}, "validations": [], "relations": {}, "acls": [

How do i setup SMTP with Loopback.io

ぃ、小莉子 提交于 2019-12-04 13:35:48
问题 How to setup SMTP server with loopback.io mbaas? i have gone through all the documentation but i couldn't find it. How to give/define my smtp server settings in loopback config file if there is way to do so. 回答1: The STMP transport can be configured in the datasources.json, for example: "mail": { "defaultForType": "mail", "connector": "mail", "transports": [ { type: 'SMTP', host: "smtp.gmail.com", // hostname secureConnection: true, // use SSL port: 465, // port for secure SMTP auth: { user:

Loopback custom method call from Android

北城以北 提交于 2019-12-04 12:55:45
I am looking for example where I can call loopback's custom method from Android. To explain more, lets say I have a method on server side with name "greet(name)" that will greet someone. I want to invoke that from Android. Any example, or link is ok. Thanks in advance. Jahid In the examples below, I'll assume your model is called Greeter and the static method Greeter.greet is invoked via GET /greeters/greet?name=Alex . First of all, you need to describe the REST mapping of your method. Then you can call the method using invokeMethod . public class GreeterRepository extends ModelRepository

How To Implement ACID Transactions in Loopback

最后都变了- 提交于 2019-12-04 12:05:29
We've been trying to implement ACID transactions in Loopback without success. The only examples in the documentation use the 'create' method.We've tried completely overriding the events as well as multiple variations of Operation Hooks. We have only been able to get the create example to work. Core Requirement : We need to be able to start a transaction in the create and update methods for a specific model and then update multiple tables in the transaction (either using Loopback's ORM functions or directly with SQL) with the ability to commit or rollback based on business rules. For example ,

StrongLoop Loopback Model find with OR condition on WHERE filter

时光毁灭记忆、已成空白 提交于 2019-12-04 06:13:48
I'm trying to find a person by either their name OR identifier using StrongLoop's Model.find syntax (documentation here: http://apidocs.strongloop.com/loopback/#modelfindfilter-callback ). But I can't figure out how to specify the OR condition. I can match both the name AND identifier using this syntax: person.find({ where: { 'name.text': {like: 'Dave'}, 'identifier.value': {like: '3303927'} } }, callback); But I'd like to be able to match name OR identifier doing something like this: person.find({ where: { 'name.text': {like: 'Dave'} || 'identifier.value': {like: '3303927'} } }, callback);

Adding a filter inside a beforeRemote remote hook

旧时模样 提交于 2019-12-04 04:50:55
I have a problem I can't find an answer to in Loopback's docs. Say I have a model Company and a model Employee . There is an 1Xn relation between the Company and its Employees . When /api/Employees is called, server returns all the employees. I only want to return the list of employees who are in the same company with the user requesting the list. For this, I created a remote hook Employee.beforeRemote('find', function(context, modelInstance, next) { var reject = function() { process.nextTick(function() { next(null, false); }); }; // do not allow anonymous users var userId = context.req

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 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