loopbackjs

Node/Nginx, 413 request entity too large, client_max_body_size set

天涯浪子 提交于 2019-12-11 09:39:20
问题 Pretty similar to https://serverfault.com/questions/539466/413-request-entity-too-large-client-max-body-size-is-set I've got a Node server (using Loopback) running on top of nginx (to be specific, the dockerfile/nginx image), but whenever I do a large PUT (or POST) request to the Node server, I get back a 413 response. I've set client_max_body_size (for me, in /etc/nginx/nginx.conf) in a number of places and to exorbitant values and yet still get the 413s... is there something I'm missing?

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

Loopback updateAttributes setting password deletes token?

孤街醉人 提交于 2019-12-11 06:17:34
问题 I got an endpoint method named 'changePassword' with http path '/:id/changePassword' inside the method i find the account by id and update the password attribute of the model but the problem is that the password do change and gets updated but also the access token gets deleted for no reason. Current Code instance.hasPassword(data.oldPassword, function(err, isMatch) { if (isMatch) { instance.updateAttributes({'password': data.password}, function(errUpdateAccount, updatedAccount) { if (

How provide dynamic message in custom loopback validation?

南笙酒味 提交于 2019-12-11 05:20:59
问题 Here is from documentation: User.validate('name', customValidator, {message: 'Bad name'}); function customValidator(err) { if (this.name === 'bad') err(); }); var user = new User({name: 'Peter'}); user.isValid(); // true user.name = 'bad'; user.isValid(); // false Is there a way to modify message variable during validation? For example, this.name === 'bad' the message is Bad name but when this.name === 'very bad' the message should be Very Bad name . How this can be done? 回答1: Suddenly there

Loopback: near filter on object sub-field

只谈情不闲聊 提交于 2019-12-11 04:15:55
问题 I have a Model like this: { name: 'My Favorite Shop', address:{ location: [12.534 /* longitude */ ,41.9221/* latitude */] } } Documents are stored in a mongodb database, and thus I'd like to query them like: //assuming shops to be the name of the containing model app.models.shops.find({ where: { 'address.location': {lat: 13, lng: 40} } }, callback); Problem is this query would not retrieve any result. I guess it's because of the nature of location field, which is nested into address , but I

Loopback inject new models from boot script

大兔子大兔子 提交于 2019-12-11 04:13:36
问题 How I can inject new models from boot script? At the moment I have model-config.json where model are configurated, but is it possible to inject those from boot script? model-config.json "MyModel": { "dataSource": "db", "public": true } my-model-bootscript.js How I can do the same in bootscript? 回答1: Here is a sample code similar to what we use in our project to create models from a boot script: const modelDefinition = { name: "ModelName", properties: { modelProperty1: { type: "string",

Loopback API include filters not working as expected

可紊 提交于 2019-12-11 03:55:48
问题 I have used different models to simplify what I am trying to achieve and to remove clutter, although the theory should be the same as my actual project. Use the following assumptions: A system can only have one type of speaker and one type of amp. Say I have the following models: *** System *** - id - name - speakerId - ampId *** Speaker *** - id - name *** Amp *** - id - name I have added the following to my System.json model file (which i think is correct): "relations": { "speakers": {

Loopback accessToken not persisted to database

橙三吉。 提交于 2019-12-11 03:47:10
问题 The access tokens created are not being persisted to the postgresql database. I created extended users and access_tokens models using the strongloop controller interface using the User and AccessToken models as parents. On login the user is successfully queried from the database, login is successful, and the access token is created. However the access token is not persisted in the database and so essentially the login fails. Inside my model_config.json I have the following entries: "access

In loopback documentation what does variable 'cb' stands for?

筅森魡賤 提交于 2019-12-11 03:33:08
问题 Look at the loopback code in their documentation http://docs.strongloop.com/display/public/LB/Defining+and+using+roles, what I am trying to understand since start is 'cb'. I understand it is some kind of callback but why it is all round the place? Does it have to do anything with Async.js?? 回答1: It has to do with the way node works asynchronously. It uses an 'event loop' that passes off other i/o functions to a background worker thread. When the background work completes the event loop