Mark Estrada
Mark Estrada

Reputation: 9191

IndexedDB IN clause equivalent

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.

Upvotes: 1

Views: 223

Answers (1)

Josh
Josh

Reputation: 18690

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.

Upvotes: 2

Related Questions