1

I am trying check if one field from a table does exists (Case In-sensitive) using Thinky ORM. Without Thinky, I can match a field just using RethinkDB simple filter-match operations:

//  This makes my variable insensitive.
let myFieldInsensitive = '(?i)^' +myFieldSensitive`enter code here`+'$';
//  Filter by matching myFieldInsensistive.
r.table('myTable').filter(r.row('myField').match(myFieldInsensitive))
 .run(myConnection, function (err, result) {
    console.log(result.length); // returns 1 if myFieldInsesitive was found
})

This code will check if the mySpecificField does exists yet in myTable (Case In-sensitive).

Now, I am trying to do the same match using Thinky, but this ORM does not support this syntax:

let myFieldInsensitive = '(?i)^' +myFieldSensitive+'$';
myModel.filter(('myField').match(myFieldInsensitive)})
  .run().then((result) => {
    console.log(result.length); // should return 1 if myFieldInsesitive was found, but this returns always empty array
})

Does anybody has idea about how can you match data in a table using Thinky?

Lucaci Sergiu
  • 564
  • 5
  • 17
  • Nice that you got it to work. :) Consider adding it as an answer below instead of a comment. – Tholle Mar 04 '16 at 17:56

1 Answers1

2

Finally did it! I have included thinky.r:

let r = thinky.r;

Instead of writing

myModel.filter(('myField').match(myFieldInsensitive))

I wrote

myModel.filter(r.row('myField').match(myFieldInsensitive))

VOILA!

alex
  • 5,467
  • 4
  • 33
  • 43
Lucaci Sergiu
  • 564
  • 5
  • 17