2016-11-15 114 views
0

我正在使用rethinkDB(刚刚开始)。我只是想搜索一个特定的字符串(甚至是一个子字符串)。 例如,如果我搜索Microsoft,给我所有包含标题微软(不区分大小写)和价格的产品较少$ 100rethinkDB在一个字符串中搜索

这是我的代码:

  //Checking product table for a certain table name 
    r.db('table').table('products').filter(function(row){ 
    return row("title").downcase().match("microsoft").and row("price").lt(100); // Should I write any regular expression here? (For microsoft?) 
     }).changes().run(conn, function(err,cursor){ 
        //cursor.each(console.log); 
    }); 

请您让​​我知道如果我在这里做错了什么?我只想搜索标题和价格?

回答

1

你应该使用REG EXPR:

r.db("table").table("products").filter(function(row){ 
    return row("title").downcase().match("(.*)microsoft(.*)").and(row("price").lt(100)); 
})