IndexedDB IN clause equivalent

2019-09-03 04:20发布

In WebSQL, I have this code

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

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.

1条回答
放我归山
2楼-- · 2019-09-03 04:47

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

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.

查看更多
登录 后发表回答