strongloop

How to Dynamically Create and Expose a New REST Endpoint In Code (on the fly) for a Custom Loopback Model

喜你入骨 提交于 2019-12-12 01:59:06
问题 We're developing a SaaS accounting product that uses the Loopback REST framework and allows authenticated end users to create new tables in their own database instance (MySQL or PostgreSQL). QUESTION : How can we create a new root level Looback REST endpoint in code (on the fly) to access the new table? For example if the user adds a new table named 'cars' we need to expose a new root level REST endpoint in code called '/api/cars' that uses the persisted model to provide full CRUD capability

How to get auto Id after upsert on a persisted model in loopback?

你离开我真会死。 提交于 2019-12-12 00:48:50
问题 I have a some models generated from postgresql db using looback-connector postgresql. Id column of these models is a auto incremented integer column of postgresql db. 1) I have a remote method added on one of persisted models, where i perform simple update or insert(upsert. Car.CreateOrUpdateCar = function (carobj, req) { Car.upsert(Carobj, function (err, Car) { if (err) console.log(err); else { req(err, Car); } }); }; 2) have added a remote hook to execute after this remote method. Car

Loopback get data from one module to anothee

蓝咒 提交于 2019-12-11 17:18:52
问题 I am using loopback3 for file storage attachment.js and i have the persistedmodel career.js for storing the data. Now i want to fetch the file name in the career.js. how to do this. career.js 'use strict'; const app = require('../../server/server'); module.exports = function(Career) { Career.afterRemote('create', function(context, remoteMethodOutput, next) { next(); // console.log(context.result) Career.app.models.Email.send({ to: 'john@gmail.com', from: 'noreply@gmail.com', subject: 'Career

loopback session no method create?

。_饼干妹妹 提交于 2019-12-11 15:14:14
问题 When I use login function User.login({email: 'foo@bar.com', password: 'bar'}, function(err, accessToken) { console.log(err); console.log(accessToken); }) the error is TypeError : Object [Model session] has no method 'create' 回答1: It looks like you are using an old version of LoopBack. Try upgrading and making sure the user model is attached to a data source. Below are the steps to do this. // # Verify version // Ω slc version // slc v2.1.1 (node v0.10.9) // # upgrade with `npm install strong

Create model in model

若如初见. 提交于 2019-12-11 12:14:23
问题 I'm new to strongloop and look at documentation and samples but never see my problem as desired. I'v two models, sentence.js and log.js and making post request a sentence from mobile app to rest-api, for example Model sentence.js (dont want save to db this model, only for parsing and creating log model) { name: 'sentence', type: 'string' } Model log.js { name: 'lat', type: 'string' }, { name: 'lng', type: 'string' } [HTTP POST] myserver/api/sentence?d=$GPRMC,123519,A,4807.038,N,01131.000,E

How do I use the access token in Loopback?

不羁的心 提交于 2019-12-11 12:04:22
问题 I am trying to use Loopback as a mobile backend. I am also following this example: http://docs.strongloop.com/display/public/LB/Introducing+the+Coffee+Shop+Reviews+app After I login on my iOS device, I receive an access token. All good. Now I want to call an endpoint that requires authentication. Just calling the endpoint gets me the message "AUTHENTICATION REQUIRED". So I try to attach the access token to the request parameters as {"access_token":"1241341234513..."}. However, nothing happens

is it possible to use StrongLoop Arc to create a relationship between two models?

戏子无情 提交于 2019-12-11 10:28:28
问题 In this loopback tutorial we can see how own can create model relationships http://docs.strongloop.com/display/public/LB/Tutorial%3A+model+relations#Tutorial:modelrelations-Createmodelrelations Is the same possible in StrongLoop Arc? Thanks 回答1: Loopback and Arc have sort of different functions. For instance the Loopback framework is a set of Node.js modules that you can use independently or together. While Arc is a visual tool suite for creating, packaging, deploying, profiling, managing,

Cannot Get specific file from s3 using Strongloop

喜欢而已 提交于 2019-12-11 10:03:50
问题 I can upload, delete and get list of folders from container(s3) but not able to get specific file from amazon S3 using Strongloop. My code: $scope.getS3Files = function(myfolderName){ //have to get all zip files in myfolderAbc $http.get('api/basePath/containerABC/files/folder1/myfolderAbc=' + myfolderName).then(function (result) { $scope.filePath = result.data; }, function (err) { toastr.error(err.data.error.message); }), }; Error: message: "Shared class "basePath" has no method handling GET

StrongLoop: EmbedsMany vs hasMany and belongTo

百般思念 提交于 2019-12-11 09:16:02
问题 My App has this Events Models. If I create another Model: Dates... so an Event can have multiple Dates, should I use Events EmbedsMany Dates? or is better to use Events hasMany Dates and Dates belongsTo Event? What's the difference? New Dates to the event might be added later after the Event been created. I might be using a MySQL database, don't know if that has something to do. 回答1: Query on model which has EmbedsMany relation will include instance(s) of related detail model in the result.

Loopback + Socket.io custom notifications

我与影子孤独终老i 提交于 2019-12-11 07:32:58
问题 I have models: Team, Project, Task. Tasks in projects, projects in teams, teams consists users. I'm creating my app like in example - https://docs.strongloop.com/display/MSG/Building+a+real-time+app+using+socket.io+and+AngularJS In my example: server/server.js ... app.use(loopback.token({ model: app.models.accessToken })); // Bootstrap the application, configure models, datasources and middleware. // Sub-apps like REST API are mounted via boot scripts. boot(app, __dirname, function(err) { if