strongloop

Social Logins authentication through loopback-passport

删除回忆录丶 提交于 2019-12-01 12:35:28
I am starting to gain grounds with loopback api . Currently I am trying to integrate authentication through social login for my app. I have found three pages that indicate how to accommplish this but they all show this a bit differently and unclear: github-loopback-component-passport & npmjs-loopback-component-passport & github-loopback-component-passport-example . I am bit confused as to what is the most up to date process. Can anyone shed some light in how to best integrate social login with loopback? Also, how to test it for routes that may require access tokens? Here is the Github Repo of

auto-increment using loopback.js and MongoDB

泄露秘密 提交于 2019-12-01 08:37:01
i want to increase mongodb document number automatically using loopback. I made function in mongo function getNextSequence(name) { var ret = db.counters.findAndModify( { query: { _id: name }, update: { $inc: { seq: 1 } }, new: true } ); return ret.seq; } db.tweet.insert( { "_id" : getNextSequence("userid"), "content": "test", "date": "1", "ownerUsername": "1", "ownerId": "1" } ) It is working in mongo shell. However when I insert using loopback.js browser ( http://localhost:3000/explorer/ ), It is not working. 400 error(SytaxError) code is showing. I can not use mongo function in loopback rest

auto-increment using loopback.js and MongoDB

ε祈祈猫儿з 提交于 2019-12-01 07:06:23
问题 i want to increase mongodb document number automatically using loopback. I made function in mongo function getNextSequence(name) { var ret = db.counters.findAndModify( { query: { _id: name }, update: { $inc: { seq: 1 } }, new: true } ); return ret.seq; } db.tweet.insert( { "_id" : getNextSequence("userid"), "content": "test", "date": "1", "ownerUsername": "1", "ownerId": "1" } ) It is working in mongo shell. However when I insert using loopback.js browser (http://localhost:3000/explorer/), It

How to configure two different datasource for a model in Strongloop Loopback framework?

*爱你&永不变心* 提交于 2019-12-01 02:20:42
问题 Our MySQL database are set up with Write clusters and Read clusters, is there a way to set up Strongloop Loopback Model (e.g. User) to Write to MySQL Host A and Read from MySQL Host B? 回答1: Try to use attachTo() if you want to change datasource for a single model. For example app.models.YourModel.attachTo(app.dataSources.readDS); readData(); ... app.models.YourModel.attachTo(app.dataSources.writeDS); writeData(); You will have to define readDS and writeDS datasources in your datasources.json

Level 2 (related model) scope over REST - strongloop api

十年热恋 提交于 2019-12-01 00:41:41
I found in the documentation that scopes enable you to specify commonly-used queries that you can reference as method calls on a model. Below i have a categories model. I am trying to create scopes that applies to the relation with model games . Unfortunately the below does nothing. How can I get scopes to apply to relation as shown below? GET /Categories/{id}/games - This gets all games common/models/category.json "relations": { "categories": { "type": "hasMany", "model": "game", "foreignKey": "" } }, /common/models/game.json "scopes": { "mature": {"where": {"mature": true}} }, "validations":

How to run multiple StrongLoop LoopBack apps on the same server?

自作多情 提交于 2019-11-30 07:34:26
I'm currently running two StrongLoop LoopBack apps (Nodejs apps) on a single server with different ports. Both apps were created using slc lb project and slc lb model from the command line. Is it possible to run these apps on a single ports with different path and/or subdomain? If it is, how do I do that on a Linux machine? Example: http://api.server.com:3000/app1/ for first app. http://api.server.com:3000/app2/ for second app. thanks. Since LoopBack applications are regular Express applications, you can mount them on a path of the master app. var app1 = require('path/to/app1'); var app2 =

Dynamic Properties or Aggregate Functions in Loopback Models

醉酒当歌 提交于 2019-11-30 07:14:18
How would I go about using aggregate functions in Loopback models? If I have a model backed by a mysql database, could I have Model1 with a hasMany relation to Model2 (with a given numeric property), and have a property in Model1 that grabs the SUM of that field from Model2? { "Model1" : { "Relations" : { "model2s" : { "type": "hasMany", "model": "Model2", "foreignKey": "model1Id" } }, "Properties" : { "total" : { "type": "Number" [SUM of Model2 'amount' field] } } }, "Model2" : { "Relations" : { "model1s" : { "type": "belongsTo", "model": "Model1", "foreignKey": "model1Id" } }, "Properties" :

Execute raw query on MySQL Loopback Connector

北慕城南 提交于 2019-11-30 07:12:27
How is it possible to execute raw query and expose results through REST API with strongloop? I've read something about using hooks and dataSource.connector.query() but I cannot find any working examples. Here is a basic example. If you have a Product model (/common/models/product.json), extend the model by adding a /common/models/product.js file: module.exports = function(Product) { Product.byCategory = function (category, cb) { var ds = Product.dataSource; var sql = "SELECT * FROM products WHERE category=?"; ds.connector.query(sql, category, function (err, products) { if (err) console.error

Destroy a model in loopback.io

你。 提交于 2019-11-30 06:14:07
How can I delete a model in strongloop's loopback.io? I have seen somewhere command called persistedModel.destroy() but when I exectute slc persistedModel.destroy() I get command not found error. Delete /common/models/your-model.js and /common/models/your-model.json , then delete the lines referencing your model in /server/model-config.json . 来源: https://stackoverflow.com/questions/28512991/destroy-a-model-in-loopback-io

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

前提是你 提交于 2019-11-29 15:33:38
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. It's not as easy as it should be to carry out a filter on some related properties. There is a pull request outstanding but it's been open for a