“无法读取未定义的属性'apply'”?在环回3

时间:2019-10-15 17:35:33

标签: loopback

我不知道为什么出现此错误 当我在回送资源管理器中执行该方法时出现错误 这是项目中使用的.js文件

'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"
        }]
    }
}

2 个答案:

答案 0 :(得分:0)

该错误是由于sql查询中的错误所致,您不能使用!null而是可以使用回送给定的neq

Puntoventa.find({ where: { nombre: { "neq": null} } }, function(err, punto) {
            if (err) return callback(err);
            return punto;
        });

答案 1 :(得分:0)

请使用{“ 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);
    });
}