2016-11-15 112 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)); 
})