你如何在Thinky ORM中匹配一个字段?

我想检查一个表中的字段是否存在(大小写敏感)使用Thinky ORM 。 没有Thinky ,我可以匹配只使用RethinkDB简单的过滤匹配操作的字段:

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

这段代码将检查mySpecificField是否存在于myTable中 (Case In-sensitive)。

现在,我正在尝试使用Thinky进行相同的匹配 ,但是此ORM不支持以下语法:

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

有人有想法,你怎么能匹配使用Thinky的表中的数据?

终于做到了! 我已经包括thinky.r

let r = thinky.r;

而不是写作

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

我写了

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

VOILA