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

Node.js 你如何在Thinky ORM中匹配一个字段?,node.js,rethinkdb,thinky,Node.js,Rethinkdb,Thinky,我正在尝试使用Thinky ORM检查表中的一个字段是否存在(区分大小写)。如果没有Thinky,我可以仅使用ReflectionDB simplefilter match操作来匹配字段: // This makes my variable insensitive. let myFieldInsensitive = '(?i)^' +myFieldSensitive`enter code here`+'$'; // Filter by matching myFieldInsensistive

我正在尝试使用Thinky ORM检查表中的一个字段是否存在(区分大小写)。如果没有Thinky,我可以仅使用ReflectionDB simplefilter match操作来匹配字段:

//  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中(区分大小写)

现在,我尝试使用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

设r=thinky.r

而不是写作

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

我写

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


很高兴你成功了。:)考虑把它作为下面的答案,而不是评论。