Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IndexedDB - boolean index

Is it possible to create an index on a Boolean type field?

Lets say the schema of the records I want to store is:

{
  id:1,
  name:"Kris",
  _dirty:true
}

I created normal not unique index (onupgradeneeded):

...
store.createIndex("dirty","_dirty",{ unique: false })
...

The index is created, but it is empty! - In the index IndexedDB browser there are no records with Boolean values - only Strings, Numbers and Dates or even Arrays.

I am using Chrome 25 canary

I would like to find all records that have _dirty attribute set to true - do I have to modify _dirty to string or int then?

like image 823
g00fy Avatar asked Dec 02 '12 19:12

g00fy


1 Answers

Yes, boolean is not a valid key.

If you must, of course you can resolve to 1 and 0.

But it is for good reason. Indexing boolean value is not informative. In your above case, you can do table scan and filter on-the-fly, rather than index query.

like image 185
Kyaw Tun Avatar answered Sep 22 '22 19:09

Kyaw Tun