Advertisement
Guest User

Firefox IndexedDB

a guest
Aug 4th, 2010
1,099
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2.     <head>
  3.         <title>Firefox 4 Beta Indexed DB</title>
  4.     </head>
  5.     <body>
  6.         <ul>
  7.             <li class = "example-set">
  8.                 <a class = "example-set-name">moz-IndexedDB</a>
  9.                 <ul>
  10.                     <li class = "example" id = "prereq">
  11.                         <a class = "example-name">Pre Requisites</a>
  12.                         <script type = "text/javascript">
  13.                             // Initialising the window.IndexedDB Object
  14.                             window.indexedDB = window.moz_indexedDB;
  15.                             var DAO = {};
  16.                         </script>
  17.                         <link class = "example-docs" href = "div#reference>div#prereq">
  18.                     </li>
  19.                     <li class = "example" id = "db" depends = "prereq">
  20.                         <a class = "example-name">Open Database</a>
  21.                         <script type="text/javascript">
  22.                             document.write("Trying to open database ...");
  23.                             var request = window.indexedDB.open("BookShop", "My Book Shop database");
  24.                             request.onsuccess = function(event){
  25.                                 DAO.db = event.result;
  26.                                 document.write("Database Opened", DAO.db);
  27.                             };
  28.                         </script>
  29.                         <link class = "example-docs" href = "div#reference>div#openDatabase">
  30.                     </li>
  31.                     <li class = "example-set">
  32.                         <a class = "example-set-name">Object Stores</a>
  33.                         <ul>
  34.                             <li class = "example" id = "objectStore" depends = "db">
  35.                                 <a class = "example-name">Open Object Stores</a>
  36.                                 <script type = "text/javascript">
  37.                                     ConsoleHelper.waitFor("DAO.db", function(){
  38.                                         document.write("Opening an Object Store using a transaction...");
  39.                                         function newTransaction(){
  40.                                             try {
  41.                                                 DAO.transaction = DAO.db.transaction(["BookList"], 0);
  42.                                                 DAO.transaction.oncomplete = newTransaction;
  43.                                                 DAO.objectStore = DAO.transaction.objectStore("BookList");
  44.                                                 document.write("Opened the object store with transaction", DAO.objectStore);
  45.                                             }
  46.                                             catch (e) {
  47.                                                 write("Could not open objectStore. You may have to create it first");
  48.                                                 writeError(e);
  49.                                                 DAO.transaction = DAO.objectStore = null;
  50.                                             }
  51.                                         }
  52.                                         newTransaction();
  53.                                     });
  54.                                 </script>
  55.                                 <link class = "example-docs" href = "div#reference>div#openObjectStore">
  56.                             </li>
  57.                             <li class = "example" depends = "db">
  58.                                 <a class = "example-name">Create Object store</a>
  59.                                 <script type = "text/javascript">
  60.                                     ConsoleHelper.waitFor("DAO.db", function(){
  61.                                         var request = DAO.db.createObjectStore("BookList", "id", true);
  62.                                         request.onsuccess = function(event){
  63.                                             document.write("Object store created", DAO.objectStore, "with transaction");
  64.                                         };
  65.                                         request.onerror = function(event){
  66.                                             document.write("Error trying to create Object store ", event);
  67.                                         };
  68.                                     });
  69.                                 </script>
  70.                                 <link class = "example-docs" href = "div#reference>div#createObjectStore">
  71.                             </li>
  72.                             <li class = "example" depends = "db">
  73.                                 <a class = "example-name">Get All Object Stores</a>
  74.                                 <script type = "text/javascript">
  75.                                     ConsoleHelper.waitFor("DAO.db", function(){
  76.                                         write("List of Object Stores", DAO.db.objectStoreNames);
  77.                                     });
  78.                                 </script>
  79.                                 <link class = "example-docs" href = "div#reference>div#getAllStores">
  80.                             </li>
  81.                             <li class = "example" depends = "db">
  82.                                 <a class = "example-name">Remove Object Store</a>
  83.                                 <script type = "text/javascript">
  84.                                     ConsoleHelper.waitFor("DAO.db", function(){
  85.                                         DAO.db.removeObjectStore("BookList");
  86.                                         write("Deleted Object store Booklist");
  87.                                     });
  88.                                 </script>
  89.                                 <link class = "example-docs" href = "div#reference>div#removeObjectStore">
  90.                             </li>
  91.                             <li class = "example-set">
  92.                                 <a class = "example-set-name">Data Operations</a>
  93.                                 <ul>
  94.                                     <li class = "example" id = "saveData" depends = "objectStore">
  95.                                         <a class = "example-name">Save Data</a>
  96.                                         <script type = "text/javascript">
  97.                                             var data = {
  98.                                                 "bookName": "Book-" + Math.random(),
  99.                                                 "author": "asdasd",
  100.                                                 "price": parseInt(Math.random() * 1000),
  101.                                                 "rating": (Math.random() > 0.5 ? "good" : "bad")
  102.                                             };
  103.                                             ConsoleHelper.waitFor("DAO.objectStore", function(){
  104.                                                 document.write("Trying to save...", data);
  105.                                                 var request = DAO.objectStore.add(data);
  106.                                                 request.onsuccess = function(event){
  107.                                                     document.write("Saved id ", event.result)
  108.                                                     DAO.objectId = event.result;
  109.                                                 };
  110.                                                 request.onerror = function(){
  111.                                                     document.write("Could not save object");
  112.                                                 };
  113.                                             });
  114.                                         </script>
  115.                                         <link class = "example-docs" href = "div#reference>div#save">
  116.                                     </li>
  117.                                     <li class = "example" depends = "saveData">
  118.                                         <a class= "example-name">Get Data</a>
  119.                                         <script type="text/javascript">
  120.                                             ConsoleHelper.waitFor("DAO.objectId", function(){
  121.                                                 document.write("Trying to get the last saved object using saved example with id ", DAO.objectId);
  122.                                                 var request = DAO.objectStore.get(DAO.objectId);
  123.                                                 request.onsuccess = function(event){
  124.                                                     document.write("Got data ", event.result)
  125.                                                     DAO.objectId = event.result;
  126.                                                 };
  127.                                                 request.onerror = function(){
  128.                                                     document.write("Could not get object");
  129.                                                 };
  130.                                             });
  131.                                         </script>
  132.                                         <link class = "example-docs" href = "div#reference>div#get">
  133.                                     </li>
  134.                                     <li class = "example" depends = "saveData">
  135.                                         <a class= "example-name">Delete Data</a>
  136.                                         <script type="text/javascript">
  137.                                             ConsoleHelper.waitFor("DAO.objectId", function(){
  138.                                                 document.write("Trying to delete the last saved object using saved example...", DAO.objectId);
  139.                                                 var request = DAO.objectStore.remove(DAO.objectId);
  140.                                                 request.onsuccess = function(event){
  141.                                                     document.write("Removed id ", event.result)
  142.                                                     DAO.objectId = event.result;
  143.                                                 };
  144.                                                 request.onerror = function(){
  145.                                                     document.write("Could not delete object");
  146.                                                 };
  147.                                             });
  148.                                         </script>
  149.                                         <link class = "example-docs" href = "div#reference>div#delete">
  150.                                     </li>
  151.                                     <li class = "example" depends = "saveData">
  152.                                         <a class = "example-name">Modify data</a>
  153.                                         <script type="text/javascript">
  154.                                             ConsoleHelper.waitFor("DAO.objectId", function(){
  155.                                                 var modifiedData = {
  156.                                                     "bookName": "Modified-" + Math.random(),
  157.                                                     "new_prop": "Modified",
  158.                                                     "rating": (Math.random() > 0.5 ? "good" : "bad"),
  159.                                                     "id": DAO.objectId
  160.                                                 };
  161.                                                 document.write("Trying to modify the last saved object using saved example...", modifiedData);
  162.                                                 var request = DAO.objectStore.modify(modifiedData);
  163.                                                 request.onsuccess = function(event){
  164.                                                     document.write("Modified id ", event.result)
  165.                                                     DAO.objectId = event.result;
  166.                                                 };
  167.                                                 request.onerror = function(){
  168.                                                     document.write("Could not modify object");
  169.                                                 };
  170.                                             });
  171.                                         </script>
  172.                                         <link class = "example-docs" href = "div#reference>div#modify">
  173.                                     </li>
  174.                                     <li class = "example" depends = "objectStore">
  175.                                         <a class = "example-name">Get All Data</a>
  176.                                         <script type = "text/javascript">
  177.                                             ConsoleHelper.waitFor("DAO.objectStore", function(){
  178.                                                 document.write("Getting all data ... ");
  179.                                                 var request = DAO.objectStore.getAll();
  180.                                                 request.onsuccess = function(event){
  181.                                                     document.write("List of objects ", event.result)
  182.                                                     DAO.objectId = event.result;
  183.                                                 };
  184.                                                 request.onerror = function(){
  185.                                                     document.write("Could not get all objects");
  186.                                                 };
  187.                                             });
  188.                                         </script>
  189.                                         <link class = "example-docs" href = "div#reference>div#getAllData">
  190.                                     </li>
  191.                                 </ul>
  192.                             </li>
  193.                         </ul>
  194.                     </li>
  195.                     <li class = "example-set">
  196.                         <a class = "example-set-name">Cursors</a>
  197.                         <ul>
  198.                             <li class = "example" id = "cursorIterator" depends = "objectStore">
  199.                                 <a class = "example-name">Open Cursor</a>
  200.                                 <script type = "text/javascript">
  201.                                     ConsoleHelper.waitFor("DAO.objectStore", function(){
  202.                                         DAO.cursorIterator = function(callback){
  203.                                             var request = DAO.objectStore.openCursor();
  204.                                             request.onsuccess = function(event){
  205.                                                 DAO.cursor = event.result;
  206.                                                 callback(DAO.cursor);
  207.                                             };
  208.                                             request.onerror = function(event){
  209.                                                 write("Could not open cursor", DAO.cursor);
  210.                                             };
  211.                                         };
  212.                                     });
  213.                                 </script>
  214.                                 <link class = "example-docs" href = "div#reference>div#cursor">
  215.                             </li>
  216.                             <li class = "example" depends = "cursorIterator">
  217.                                 <a class = "example-name">Iterate on data</a>
  218.                                 <script type = "text/javascript">
  219.                                     ConsoleHelper.waitFor("DAO.cursorIterator", function(){
  220.                                         DAO.cursorIterator(function(cursor){
  221.                                             if (!cursor) {
  222.                                                 return;
  223.                                             }
  224.                                             write(DAO.cursor.key, DAO.cursor.value);
  225.                                             DAO.cursor["continue"]();
  226.                                         });
  227.                                     });
  228.                                 </script>
  229.                                 <link class = "example-docs" href = "div#reference>div#cursor_continue">
  230.                             </li>
  231.                             <li class = "example" depends = "cursorIterator">
  232.                                 <a class = "example-name">Remove All Objects</a>
  233.                                 <script type = "text/javascript">
  234.                                     ConsoleHelper.waitFor("DAO.iterateOnCursor", function(){
  235.                                         DAO.cursorIterator(function(cursor){
  236.                                             if (!cursor) {
  237.                                                 return;
  238.                                             }
  239.                                             write("Removing", cursor.key, cursor.value);
  240.                                             DAO.cursor.remove();
  241.                                             DAO.cursor["continue"]();
  242.                                         });
  243.                                     });
  244.                                 </script>
  245.                                 <link class = "example-docs" href = "div#reference>div#cursor_remove">
  246.                             </li>
  247.                             <li class = "example" depends = "cursorIterator">
  248.                                 <a class = "example-name">Update data</a>
  249.                                 <script type = "text/javascript">
  250.                                     ConsoleHelper.waitFor("DAO.iterateOnCursor", function(){
  251.                                         DAO.cursorIterator(function(cursor){
  252.                                             if (!cursor) {
  253.                                                 return;
  254.                                             }
  255.                                             cursor.value["new_prop_cursor"] = Math.random();
  256.                                             write("Updating", cursor.key, cursor.value);
  257.                                             DAO.cursor.update(cursor.value);
  258.                                             DAO.cursor["continue"]();
  259.                                         });
  260.                                     });
  261.                                 </script>
  262.                                 <link class = "example-docs" href = "div#reference>div#cursor_update">
  263.                             </li>
  264.                         </ul>
  265.                     </li>
  266.                     <li class = "example-set">
  267.                         <a class = "example-set-name">Indexes</a>
  268.                         <ul>
  269.                             <li class = "example" depends = "objectStore">
  270.                                 <a class = "example-name">List Indexes</a>
  271.                                 <script type = "text/javascript">
  272.                                     ConsoleHelper.waitFor("DAO.objectStore", function(){
  273.                                         write("Indexes", DAO.objectStore.indexNames);
  274.                                     });
  275.                                 </script>
  276.                                 <link class = "example-docs" href = "div#reference>div#index_names">
  277.                             </li>
  278.                             <li class = "example" depends = "objectStore">
  279.                                 <a class = "example-name">Create Index</a>
  280.                                 <script type = "text/javascript">
  281.                                     ConsoleHelper.waitFor("DAO.objectStore", function(){
  282.                                         DAO.objectStore.createIndex("priceIndex", "price", false);
  283.                                         write("Index created");
  284.                                     });
  285.                                 </script>
  286.                                 <link class = "example-docs" href = "div#reference>div#index_create">
  287.                             </li>
  288.                             <li class = "example" depends = "objectStore" id = "index">
  289.                                 <a class = "example-name">Open Index</a>
  290.                                 <script type = "text/javascript">
  291.                                     ConsoleHelper.waitFor("DAO.objectStore", function(){
  292.                                         try {
  293.                                             DAO.index = DAO.objectStore.index("priceIndex");
  294.                                             write("Opened Index", DAO.index);
  295.                                         }
  296.                                         catch (e) {
  297.                                             write("Could not open Index, create it first");
  298.                                             writeError(e);
  299.                                         }
  300.                                     });
  301.                                 </script>
  302.                                 <link class = "example-docs" href = "div#reference>div#index_open">
  303.                             </li>
  304.                             <li class = "example" depends = "objectStore">
  305.                                 <a class = "example-name">Remove Index</a>
  306.                                 <script type = "text/javascript">
  307.                                     ConsoleHelper.waitFor("DAO.objectStore", function(){
  308.                                         try {
  309.                                             DAO.objectStore.removeIndex("priceIndex");
  310.                                             write("Removed Index", DAO.index);
  311.                                             delete DAO.index;
  312.                                         }
  313.                                         catch (e) {
  314.                                             write("Could not remove Index, create it first");
  315.                                             writeError(e);
  316.                                         }
  317.                                        
  318.                                     });
  319.                                 </script>
  320.                                 <link class = "example-docs" href = "div#reference>div#index_remove">
  321.                             </li>
  322.                             <li class = "example" depends = "index">
  323.                                 <a class = "example-name">Cursor on Index</a>
  324.                                 <script type = "text/javascript">
  325.                                     ConsoleHelper.waitFor("DAO.index", function(){
  326.                                         write("Starting to iterate on object cursor...");
  327.                                         var request = DAO.index.openCursor();
  328.                                         request.onsuccess = function(event){
  329.                                             var objectCursor = event.result;
  330.                                             if (!objectCursor) {
  331.                                                 return;
  332.                                             }
  333.                                             write(objectCursor);
  334.                                             objectCursor["continue"]();
  335.                                         };
  336.                                         request.onerror = function(event){
  337.                                             write("Could not open Object Store", event);
  338.                                         };
  339.                                     });
  340.                                 </script>
  341.                                 <link class = "example-docs" href = "div#reference>div#index_cursor">
  342.                             </li>
  343.                             <li class = "example" depends = "index">
  344.                                 <a class = "example-name">Object Cursor on Index</a>
  345.                                 <script type = "text/javascript">
  346.                                     ConsoleHelper.waitFor("DAO.index", function(){
  347.                                         write("Starting to iterate on object cursor...");
  348.                                         var request = DAO.index.openObjectCursor();
  349.                                         request.onsuccess = function(event){
  350.                                             var objectCursor = event.result;
  351.                                             if (!objectCursor) {
  352.                                                 return;
  353.                                             }
  354.                                             write(objectCursor, DAO.index);
  355.                                             objectCursor["continue"]();
  356.                                         };
  357.                                         request.onerror = function(event){
  358.                                             write("Could not open Object Store", event);
  359.                                         };
  360.                                     });
  361.                                 </script>
  362.                                 <link class = "example-docs" href = "div#reference>div#index_objectCursor">
  363.                             </li>
  364.                         </ul>
  365.                     </li>
  366.                     <li class = "example" depends = "db">
  367.                         <a class = "example-name">Set Version</a>
  368.                         <script type = "text/javascript">
  369.                             ConsoleHelper.waitFor("DAO.db", function(){
  370.                                 var request = DAO.db.setVersion(parseInt(Math.random() * 100));
  371.                                 request.onsuccess = function(){
  372.                                     write("Set the version of the database to", DAO.db.version);
  373.                                 };
  374.                             });
  375.                         </script>
  376.                         <link class = "example-docs" href = "div#reference>div#version">
  377.                     </li>
  378.                 </ul>
  379.             </li>
  380.         </ul>
  381.         <div id = "reference">
  382.             <div id = "prereq">
  383.                 <h3>Pre Requisites</h3>
  384.                 <p>
  385.                     Firefox 4.0 implements the <a target = '_blank' href = '../firefox/Speclet_023_IDB_API_Asynchronous_APIs.html'>IndexedDB</a>
  386.                     as window.moz_indexedDB. The pre requisities function assigns it to the Window object. The examples here show the asynchronous API. Hence, dependencies are loaded using a ConsoleHelper.waitFor function that waits for a specific variable to get defined by examples that are required for this example to run.
  387.                 </p>
  388.                 <p>
  389.                     You can find more details about IndexedDB <a target = '_blank' href = 'http://hacks.mozilla.org/2010/06/comparing-indexeddb-and-webdatabase/'>here</a>, <a target="_blank" href = 'http://hacks.mozilla.org/2010/06/comparing-indexeddb-and-webdatabase/'>here</a>
  390.                     and <a target = '_blank' href = "http://hacks.mozilla.org/2010/06/beyond-html5-database-apis-and-the-road-to-indexeddb/">here</a>.
  391.                 </p>
  392.                 <p>
  393.                     If you get errors trying to run examples, make sure that you hit the "Load-Prerequisites" button at the top right.
  394.                 </p>
  395.             </div>
  396.             <div id = "openDatabase">
  397.                 <h3>Open Database</h3>
  398.                 <p>
  399.                     This method returns immediately and runs the following steps in a different thread. If an error occurs while the database connection is being opened, then an error event is fired on this method's returned object with its code set to UNKNOWN_ERR  and a suitable message.
  400.                     <ol>
  401.                         <li>
  402.                             Let origin be the origin of the active document from which the method was invoked.
  403.                         </li>
  404.                         <li>
  405.                             Perform the steps for opening a database, with origin, the name parameter and description parameter, and call its result as result.
  406.                         </li>
  407.                         <li>
  408.                             If the steps were aborted with an error code, then set this request's error with that code and abort these steps.
  409.                         </li>
  410.                         <li>
  411.                             Create a IDBDatabase object for result and call it db.
  412.                         </li>
  413.                         <li>
  414.                             Fire a success event on this method's returned object using the IDBSuccessEvent interface with its result set to db.
  415.                         </li>
  416.                     </ol>
  417.                 </p>
  418.                 <p>
  419.                     A database object can be used to manipulate the objects of that database. That is also the only way to obtaining a transaction for that database.
  420.                 </p>
  421.                 <a href = "http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBFactory-open">http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBFactory-open</a>
  422.             </div>
  423.             <div id = "openObjectStore">
  424.                 <h3>Open Object Store</h3>
  425.                 <p>
  426.                     Creates a new read_write transaction. Opens an object store in the read write mode. The oncomplete callback of the transaction opens anothe transaction.
  427.                 </p>
  428.                 <a target = "_blank" href = "http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBDatabase-objectStore">http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBDatabase-objectStore</a>
  429.             </div>
  430.             <div id = "createObjectStore">
  431.                 <h3>Create Object Store</h3>
  432.                 <p>
  433.                     This method creates and returns a new object store with the given name in the connected database. Note that this method must only be called from a VERSION_CHANGE transaction callback.
  434.                 </p>
  435.                 <a target="_blank" href = "http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBDatabase-createObjectStore">http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBDatabase-createObjectStore</a>
  436.             </div>
  437.             <div id = "removeObjectStore">
  438.                 <h3>Remove Object Store</h3>
  439.                 <p>
  440.                     This method destroys the object store with the given name in the connected database as well as all indexes that are referencing that object store. Note that this method must only be called from a VERSION_CHANGE  transaction callback.
  441.                 </p>
  442.                 <a target="_blank" href= "http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBDatabase-removeObjectStore">http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBDatabase-removeObjectStore</a>
  443.             </div>
  444.             <div id = "save">
  445.                 <h3>Save Data</h3>
  446.                 <p>
  447.                     This method returns immediately and stores the given value in this object store by following the steps for storing a record into an object store with the no-overwrite flag set. If the record can be successfully stored in the object store, then a success event is fired on this method's returned object using the IDBTransactionEvent interface with its result set to the key for the stored record and transaction set to the transaction in which this object store is opened. If a record exists in this object store for the key key parameter, then an error event is fired on this method's returned object with its code set to CONSTRAINT_ERR
  448.                 </p>
  449.                 <a target="_blank" href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBObjectStore-add">http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBObjectStore-add</a>
  450.             </div>
  451.             <div id = "delete">
  452.                 <h3>Delete data</h3>
  453.                 <p>
  454.                     This method returns immediately and removes the record from this object store by following the steps for deleting a record from an object store corresponding to the given key. If a record did not exist in this object store for the key parameter, then an error event is fired on this method's returned object with its code set to NOT_FOUND_ERR  and a suitable message. If the record can be successfully removed from the object store, then a success event is fired on this method's returned object using the IDBTransactionEvent interface with its result set to the value of the removed record and transaction set to the transaction in which this object store is opened.
  455.                 </p>
  456.                 <a target="_blank" href= "http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBObjectStore-remove">http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBObjectStore-remove</a>
  457.             </div>
  458.             <div id = "modify">
  459.                 <h3>Update data</h3>
  460.                 <p>
  461.                     This method returns immediately and stores the given value in this object store by following the steps for storing a record into an object store. If the record can be successfully stored in the object store, then a success event is fired on this method's returned object using the IDBTransactionEvent interface with its result set to the key for the stored record and transaction set to the transaction in which this object store is opened.
  462.                 </p>
  463.                 <a target="_blank" href ="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBObjectStore-put">http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBObjectStore-put</a>
  464.             </div>
  465.             <div id = "get">
  466.                 <h3>Get Data</h3>
  467.                 <p>
  468.                     This method returns immediately and retrieves the value from this object store for the record corresponding to the given key by following the steps for retrieving a record from an object store. If the operation is successful, then the result of this object's request is set to the retrieved value. If a record did not exist in this object store for the key key parameter, then an error event is fired on this method's returned object with its code set to NOT_FOUND_ERR  and a suitable message. If the record can be successfully retrieved from the object store, then a success event is fired on this method's returned object using the IDBTransactionEvent interface with its result set to the value of the retrieved record and transaction set to the transaction in which this object store is opened.
  469.                 </p>
  470.                 <a target="_blank" href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBObjectStore-get">http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBObjectStore-get</a>
  471.             </div>
  472.             <div id = "cursor">
  473.                 <h3>Open Cursor</h3>
  474.                 <p>
  475.                     This method returns immediately and creates a cursor over the records of this object store. The range of this cursor matches the key range specified as the range parameter, or if that parameter is not specified or null, then the range includes all the records. If there is even a single record that matches the key range, then a success event is fired on this method's returned object with its result set to the IDBCursor object for that cursor. If no records match the key range, then an success event is fired on this method's returned object with its result  set to null.
  476.                 </p>
  477.                 <p>
  478.                     The function defined here is used by other cursor methods.
  479.                 </p>
  480.                 <a target="_blank" href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBObjectStore-openCursor">http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBObjectStore-openCursor</a>
  481.             </div>
  482.             <div id = "cursor_continue">
  483.                 <h3>Iterate over Cursor</h3>
  484.                 <p>
  485.                     This method returns immediately and advances the cursor to the next position along its direction to the item whose key matches the optional parameter. If no such parameter is provided, advance to the immediate next position. If the cursor has reached the end of its range, then an success event is fired on this method's returned object with its result  set to null.
  486.                 </p>
  487.                 <a target="_blank" href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBCursor-continue">http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBCursor-continue</a>
  488.             </div>
  489.             <div id = "cursor_remove">
  490.                 <h3>Remove Objects using Cursor</h3>
  491.                 <p>
  492.                     This method returns immediately and deletes the object at the cursor's position. The cursor's position is not changed. Any attempts to retrieve the cursor's current value will return null.
  493.                 </p>
  494.                 <a target="_blank" href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBCursor-remove">http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBCursor-remove</a>
  495.             </div>
  496.             <div id = "cursor_update">
  497.                 <h3>Update Objects using Cursor</h3>
  498.                 <p>
  499.                     This method returns immediately and sets the value for the record at the cursor's position.
  500.                 </p>
  501.                 <a target="_blank" href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBCursor-update">http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBCursor-update</a>
  502.             </div>
  503.             <div id = "index_names">
  504.                 <h3>Get Index Names</h3>
  505.                 <p>
  506.                     Gets all the indexes that are defined on the object store
  507.                 </p>
  508.             </div>
  509.             <div id = "index_create">
  510.                 <h3>Create Index</h3>
  511.                 <p>
  512.                     This creates and returns a new index with the given name and parameters in the connected database. Note that this method must only be called from a VERSION_CHANGE transaction callback.
  513.                 </p>
  514.                 <a target="_blank" href= "http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBObjectStore-createIndex">http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBObjectStore-createIndex</a>
  515.             </div>
  516.             <div id = "index_objectCursor">
  517.                 <h3>Get Object Cursor on Index</h3>
  518.                 <p>
  519.                     This method returns immediately and creates a cursor over the records of this index's referenced object store as arranged by this index. The range of this cursor matches the key range specified as the range parameter, or if that parameter is not specified or null, then the range includes all the records. If there is even a single record that matches the key range, then a success event is fired on this method's returned object with its result set to the IDBCursor object for that cursor. If no records match the key range, then an error event is fired on this method's returned object with its code set to NOT_FOUND_ERR  and a suitable message.
  520.                 </p>
  521.                 <a target="_blank" href = "http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBIndex-openObjectCursor">http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBIndex-openObjectCursor</a>
  522.             </div>
  523.             <div id = "index_cursor">
  524.                 <h3>Get Cursor on Index</h3>
  525.                 <p>
  526.                     This method returns immediately and creates a cursor over the records of this index. The range of this cursor  matches the key range specified as the range parameter, or if that parameter is not specified or null, then the range includes all the records. If there is even a single record that matches the key range, then a success event is fired on this method's returned object with its result set to the IDBCursor object for that cursor. If no records match the key range, then an error event is fired on this method's returned object with its code set to NOT_FOUND_ERR  and a suitable message.
  527.                 </p>
  528.                 <a target="_blank" href= "http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBIndex-openCursor">http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBIndex-openCursor</a>
  529.             </div>
  530.             <div id = "index_open">
  531.                 <h3>Open Index</h3>
  532.                 <p>
  533.                     This method returns immediately and opens the index with the given name in the connected database.
  534.                 </p>
  535.                 <a target="_blank" href = "http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBObjectStore-index">http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBObjectStore-index</a>
  536.             </div>
  537.             <div id = "index_remove">
  538.                 <h3>Remove Index</h3>
  539.                 <p>
  540.                     This method destroys the index with the given name in the connected database. Note that this method must only be called from a VERSION_CHANGE  transaction callback.
  541.                 </p>
  542.                 <a target="_blank" href= "http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBObjectStore-removeIndex">http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBObjectStore-removeIndex</a>
  543.             </div>
  544.             <div id = "version">
  545.                 <h3>Set Database Version</h3>
  546.                 <p>
  547.                     This method returns immediately and sets the version of the connected database.
  548.                 </p>
  549.                 <a target="_blank" href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBDatabase-setVersion">http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Speclet_023_IDB_API_Asynchronous_APIs.html#widl-IDBDatabase-setVersion</a>
  550.             </div>
  551.             <div id = "getAllStores">
  552.                 <h3>Get All objects in data store</h3>
  553.                 <p>
  554.                     Gets all the object stores in the database
  555.                 </p>
  556.             </div>
  557.             <div id = "getAllData">
  558.                 <h3>Get All objects in data store</h3>
  559.                 <p>
  560.                     Gets all the objects in the object store
  561.                 </p>
  562.             </div>
  563.         </div>
  564.     </body>
  565. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement