IndexedDB IN clause equivalent

戏子无情 提交于 2019-12-12 04:55:05

问题


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:


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.



来源:https://stackoverflow.com/questions/25299547/indexeddb-in-clause-equivalent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!