1

我正在尝试使用 oriento db 接口进行自动完成工作。

网络服务器是带有 express 框架的 nodeJS,服务器代码是这样的:

express.get("/piatti", function(req, res) {
    var tipo = req.query.tipo;
    var nome = req.query.nome;

    var filtriRicerca = {};
    var tabella = modules.database.db.select().from('PIATTI');

    if(tipo) {
        filtriRicerca.tipo = tipo;
    }

    if(nome) {
        filtriRicerca.nome = nome;
    }

    console.log(JSON.stringify(filtriRicerca));

    if(Object.keys(filtriRicerca).length) {
        console.log("Aggiunto il filtro");
        tabella = tabella.where(filtriRicerca);
    }

    tabella.all().then(function (piatti) {
        res.json(piatti);
    });
});

我不知道如何让 where 子句像 filtriRicerca.nome% 一样工作。

在此先感谢,马蒂亚

4

1 回答 1

1

Mattia,您的问题的一个可能的替代解决方案是将 Waterline ORM 与sails-orientdb适配器一起使用。Sails-orientdb 使用 Oriento,因此您可以随时访问 Oriento 的方法,并且可以进行like如下查询:

Model.find({ food: { 'like': '%beans' }})

更多关于水线文档的示例。

于 2015-04-21T10:53:39.167 回答