首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >“无法读取未定义的属性'apply‘”?在环回3

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

Stack Overflow用户
提问于 2019-10-16 01:35:33
回答 2查看 144关注 0票数 0

我不知道为什么当我在loopback explorer中执行方法时会出现这个错误: this is the .js file in the project

代码语言:javascript
复制
'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模型

代码语言:javascript
复制
"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"
        }]
    }
}
EN

回答 2

Stack Overflow用户

发布于 2019-10-16 16:49:35

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

代码语言:javascript
复制
Puntoventa.find({ where: { nombre: { "neq": null} } }, function(err, punto) {
            if (err) return callback(err);
            return punto;
        });
票数 1
EN

Stack Overflow用户

发布于 2019-10-23 18:36:19

请使用{ "neq":null} }并在getAll()中定义回调。

代码语言:javascript
复制
 Puntoventa.getAll = function(callback) {
    Puntoventa.find({ where: { nombre: { "neq": null} } } }, function(err, punto) {
        if (err) return callback(err);
        return callback(null,punto);
    });
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58399929

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档