HTML and CSS Reference
In-Depth Information
The options object has two properties that serve as flag parameters. The first flag,
unique , allows the application to specify whether or not a key can be shared. The second
flag, multiEntry , allows the application to specify how to handle array-based keys:
Either enter an object under several different keys listed in an array, or enter an object using
the entire array as a key. You won't need to use the second flag in the My Tasks application
(for more detail about multiEntry, see appendix B or www.w3.org/TR/IndexedDB/
#dfn-multientry ) .
Let's look at the database-creation process and apply it to our application.
Step 2: Connect to the database and create an object store
You will need to create an object store, “tasks”, for all the tasks the user will want to keep
track of. Remember to first create the database connection, because you'll need this to cre-
ate the object store and the index. You'll use the index to access the object store by the
task's description. This will be useful when you implement the application's search engine
that allows the user to filter their task list by a task's description.
You'll also add a call to the loadTasks function here. It's not related to object store or in-
dex creation, but it will be useful later when the application is in the startup phase and needs
to load the existing task objects into the Task List view. You'll implement loadTasks
later in this section.
The following listing might seem like a lot of code, but it's doing quite a bit for us: opening
a database connection, creating an object store, and providing a Web SQL fallback for
browsers that don't support IndexedDB. Add the code from this listing to app.js, just below
the code you added from listing 5.9 .
Search WWH ::




Custom Search