我不知道为什么当我在loopback explorer中执行方法时会出现这个错误: this is the .js file in the project
'use strict';
module.exports = function(Puntoventa) {
var app = require('../../server/server');
Puntoventa.getAll = function() {
Puntoventa.find({ where: { nombre: !null } }, function(err, punto) {
if (err) return callback(err);
return punto;
});
}
}这是.json模型
"name": "puntoVenta",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"acls": [],
"methods": {
"getAll": {
"accepts": [],
"returns": [{
"arg": "punto",
"type": "object",
"root": true,
}],
"http": [{
"path": "/getAll",
"verb": "get"
}]
}
}发布于 2019-10-16 16:49:35
该错误是由于sql查询中的错误造成的,您不能使用!null,而可以使用由loopback提供的neq
Puntoventa.find({ where: { nombre: { "neq": null} } }, function(err, punto) {
if (err) return callback(err);
return punto;
});发布于 2019-10-23 18:36:19
请使用{ "neq":null} }并在getAll()中定义回调。
Puntoventa.getAll = function(callback) {
Puntoventa.find({ where: { nombre: { "neq": null} } } }, function(err, punto) {
if (err) return callback(err);
return callback(null,punto);
});
}https://stackoverflow.com/questions/58399929
复制相似问题