我正在尝试使用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中(不区分大小写)。
现在,我正在尝试使用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匹配表中的数据吗?