0

I'm using rethinkDB (Just started). I just wanted to search a particular string(or even a substring). For example, if I search for microsoft, give me all the products which contain title microsoft (case insensitive) and price less than $100

This is my code:

            //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);
   });

Please kindly let me know if i'm doing anything wrong here? I just want to search for title and price?

TechnoCorner
  • 4,879
  • 10
  • 43
  • 81

1 Answers1

1

You should use reg expr:

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