HTML and CSS Reference
In-Depth Information
with tasks as the object store to search and a transaction type of 'readonly' . The ap-
plication could use the read/write option, but the search performance would be slower.
Once the transaction is defined, you then need to extract the index from the object store.
The index will enable the application to filter the object store based on some property of
the object. In your application, the index's key is based on the task's description property.
Using this index and a string describing some portion of the task description, you'll create
a database cursor using the IndexedDB API method openCursor . The application will
then use this cursor's continue method to iterate over the database and find all of the
tasks containing a portion of the task description.
Using cursors to iterate through database records
Cursor is a generic term describing a control structure in a database that allows you to iter-
ate through the records stored in it. Cursors typically enable you to filter out records based
on certain characteristics and to define the order in which the result set is returned. Using
the cursor's continue method, you can then sequentially move through the record set re-
turned by the cursor, retrieving the data for use in your applications. Cursors in IndexedDB
allow you to traverse a result set that's defined by a key range, moving in a direction of
either an increasing or decreasing order of keys.
Step 4: Implement a search engine for the database and display search results
In the application, the loadTasks function is responsible for retrieving and displaying
tasks from the IndexedDB or Web SQL database. loadTasks will either retrieve a
filtered set of tasks or all tasks and then pass them to the showTask function, which will
render them onto the Task List view. Add the code from the next listing immediately after
the code from the previous listing.
Search WWH ::

Custom Search