IndexedDB IN子句等效 [英] IndexedDB IN clause equivalent

查看:94
本文介绍了IndexedDB IN子句等效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在WebSQL中,我有这段代码

In WebSQL, I have this code

tx.executeSql('select * from TABLE where FIELD IN (? ,? ,?) ;', ['REGULAR', 'FULL' , 'CONTRACTUAL' ])

IndexedDB中是否有类似的构造?我正在查看IDBKeyRange.bound,但只是想确保它匹配.

Is there a similar construct in IndexedDB? I was looking at the IDBKeyRange.bound but just would like to make sure that it will match up.

推荐答案

您无法在indexedDB中执行field = value1 or field = value2的等效功能.

You cannot perform the equivalent of field = value1 or field = value2 in indexedDB.

这是我的解决方法.使用整数常量表示FIELD的类别.例如,"1"表示常规","2"表示完整","3"表示合同".对常数进行排序,以使数字连续.然后使用IDBKeyRange,其下限为所需的最低常数,上限为最高常数.

Off the top of my head, here is a workaround. Use integer constants to represent the categories of FIELD. For example, 1 for REGULAR, 2 for FULL, and 3 for CONTRACTUAL. Order the constants such that the numbers are consecutive. Then use IDBKeyRange with lower bound on the lowest desired constant and upper bound on the highest constant.

这篇关于IndexedDB IN子句等效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆