Question

I am using WinJS and IndexDB to support a metro app I'm writing. I need to maintain 2 lists of information. I could use the same DB and store the same object for both lists if I could filter on a field but I can't find a method to support filtering from an IndexDB.

As that hasn't worked then I thought I'd just use 2 IndexDB's. My metro app is just throwing an exception with no other details that an error 2.

Can I use multiple IndexDB in one page of a Metro app?

Is filtering possible with IndexDBs?

Even the results from the IndexDB seem to be hidden as I can't even manually filter after I've got all the results.

Was it helpful?

Solution

Depends what you mean by multiple indexedDB -- You can't open multiple DB instances, but you can query the database multiple times, and get multiple datasets. The DB will return the full object for the record.

Also, what kind of filtering are you trying to do?

Note that the indexedDB has no direct query language for selecting based on a filter. You do have a couple of options:

  • Use indexes on the object stores, and use that for "Exact" matches (E.g. a image type or what not)
  • Filter the content when it's returned from the DB results, and only return that to something else.

There is a nice fork of Aaron Powells db.js at https://github.com/grork/db.js that provides a nice WinJS promise compatible API.

OTHER TIPS

I've seen this question has been anwsered already, but I want to note that I'm busy writing a library around indexeddb that supports querying on it. Even filters that aren't possible with the indexeddb API are solved in my library.

FYI take a look at this link. It's also WinJS compatible and every thing is wrapped in promises.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top