首页 > 解决方案 > “无法读取未定义的属性‘应用’”?在环回 3

问题描述

我不知道为什么当我在环回资源管理器中执行该方法时出现此错误给出了错误 This is the .js file used 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"
        }]
    }
}

标签: loopback

解决方案


该错误是由于 sql 查询中的错误,您不能使用 !null 而是可以使用 loopback 给出的 neq

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

推荐阅读