环回:如何查询对象数组?

时间:2018-12-15 13:58:26

标签: loopbackjs

如何在回送3中查询数组?

我有以下方法:

//h1[contains(., "Demarcation")]/preceding-sibling::p[contains(., "Yes")]

但是我遇到以下错误:

Driver.reserve = async function(cb) {

    let query = {
        where: {
            preferred_delivery_days: {
                elemMatch: {
                    availability: 0
                }
            }
        }
    };

    return await app.models.Driver.find(query);
};

以下是数据库条目的示例:

code: ER_PARSE_ERROR

errno: 1064

sqlMessage: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''{\"availability\":0}' ORDER BY `id`' at line 1

sqlState: 42000

sql: SELECT 
driver021489826505814413.`first_name`,driver021489826505814413.`last_name`,driver021489826505814413.`gender`,driver021489826505814413.`preferred_delivery_days` FROM `my_driver_table` driver021489826505814413 WHERE driver021489826505814413.`preferred_delivery_days`'{\"availability\":0}' ORDER BY `id`

1 个答案:

答案 0 :(得分:0)

我认为这可能很难,因为根据docs

  

关系数据库的数据源连接器不支持过滤嵌套属性。

如果您的项目处于开始阶段,则可以考虑将db更改为mongo或其他no-sql db?