loopbackjs

strongloop/loopback - Maintain multiple versions of API

我们两清 提交于 2019-12-22 11:08:53
问题 I am using strongloop/loopback for the first time. There is some rudimentary instruction online for versioning an API: var p = require('../package.json'); var version = p.version.split('.').shift(); module.exports = { restApiRoot: '/api' + (version > 0 ? '/v' + version : ''), host: process.env.HOST || 'localhost', port: process.env.PORT || 3000 }; What I don't see, is a recommended way of maintaining multiple versions of an API. So, for example, I could have a legacy 1.4 version and new 2.0

How do I get the MongoDb connection from inside Loopback.io

心已入冬 提交于 2019-12-22 09:30:53
问题 I'm writing a remote method that would be greatly enhanced by running an aggregation pipeline query. To do that I need to get the actual mongodb connection and work with it directly. How can I run something along the lines of module.exports = function(ZipCodes) { ZipCodes.pipeline = function (cb) { //Get the MongoDB Connection var mongodbConnection = ***whatever magic*** var result = mongodbConnection.db.zipcodes.aggregate( { $group : { _id : "$state", totalPop : { $sum : "$pop" } } }, {

How To Implement ACID Transactions in Loopback

寵の児 提交于 2019-12-21 20:13:39
问题 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

OAuth 2.0 OpenID Connect Loopback and Keycloak

自古美人都是妖i 提交于 2019-12-21 20:09:07
问题 I'm unable to connect to Keycloak from Loopback. I've been trying to use the keycloak-connect lib: https://github.com/keycloak/keycloak-nodejs-connect This is my current server/boot/root.js module.exports = function (server) { var session = require('express-session'); var Keycloak = require('keycloak-connect'); var memoryStore = new session.MemoryStore(); var keycloak = new Keycloak({ store: memoryStore }); server.use(session({ secret: 'xxx', resave: false, saveUninitialized: true, store:

Loopback relationship on non id field

∥☆過路亽.° 提交于 2019-12-21 12:57:38
问题 I want to specify the relationship betweet 2 mssql tables. Paymentcategory and Payout. paymentcategory.id joins on the payout.category column. in payout.json model I specified as foreignKey: id, "relations": { "paymentcategories": { "type": "hasOne", "model": "Paymentcategory", "foreignKey": "id" } but loopback looks by default for the id field as primaryKey Is there a way to specify the join on the category field. Preferably in the common/models/payout.json file? "relations": {

How to setup OAuth 2.0 server using loopback

北慕城南 提交于 2019-12-21 07:14:32
问题 I want to setup an OAuth 2.0 Server using Loopback using a package called loopback-component-oauth2 The documentation is here : https://docs.strongloop.com/display/public/LB/OAuth+2.0#OAuth2.0-UsingtheOAuth2component But it is very unclear, what models should i create and what rest endpoint should be defined? Please help! 回答1: First of all, it's important to note that the documentation might be outdated: After IBM’s acquisition of StrongLoop, we have integrated strong-gateway with the latest

Loopback4 connect to Elasticsearch

时光总嘲笑我的痴心妄想 提交于 2019-12-21 05:00:21
问题 How to connect loopback4 server app with Elasticsearch DB. I have tried with below reference links. but they have not explained for loopback4. And have did same implementation using below references but not able creating mapping properly to fetch records. https://loopback.io/doc/en/community/Elasticsearch-connector.html https://github.com/strongloop-community/loopback-connector-elastic-search/tree/feature/esv6 { "name": "customer", "connector": "esv6", "index": "index_name", "hosts": [ {

Loopback discoverAndBuildModels not generating models

亡梦爱人 提交于 2019-12-20 12:28:53
问题 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

Make a join query in loopback.io

旧巷老猫 提交于 2019-12-19 09:47:18
问题 I am trying to build a simple application using loopback.io as process of my learning. I have set up the project, created models and apis are working fine. Now I am trying to create a custom api which can get the data from two different models by making a join query. So i have a two models stories : id, title, noteId notes : id , desc i have stories.js file as module.exports = function(Stories) { Stories.list = function(cb) { // make a join query }; Stories.remoteMethod( 'list', { http: {

Loopback 4: Upload multipart/form-data via POST method

冷暖自知 提交于 2019-12-19 04:02:55
问题 I'm working in Loopback 4 and getting stuck in creating a POST method so that client can call this method and upload a multipart/form-data. I read some examples: https://medium.com/@jackrobertscott/upload-files-to-aws-s3-in-loopback-29a3f01119f4 https://github.com/strongloop/loopback-example-storage But, look like they are not suitable for Loopback 4. Could you help me to upload multipart/form-data via POST method in Loopback4. 回答1: Support for multipart/form-data was added to LoopBack 4