angularjs - Update model value in boot script by id in loopback? -


i'm using code in 1 of server boot script-

var server = require('../server'); var ds = server.datasources.mysql;  var express = require('express'); var request = require('request'); var router  = express.router();  module.exports = function(app) {  app.get('/test',function(req,res){     //console.log(server.model);     server.models.company.update({         filter: {             where: {                 id: 1                 },             },         },         name: 's12'     }); }); }; 

the problem updates row in database. how should make function updates name id 1.

please me this.

jerome wagner right when says there isn't update method - it's updateall. furthermore shouldn't use full filter syntax non query methods, , need include callback method. from docs:

when call node apis methods other queries, don't wrap clause in { : ... } object...

so example should be:

app.get('/test',function(req,res){     //console.log(server.model);     server.models.company.updateall({ id: 1 }, { name: 's12' }, function(err, info) {         ...     }); }); 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -