Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /** | |
| 2 * A client-side key-value store with support for indexes. | |
| 3 * | |
| 4 * Many browsers support IndexedDB—a web standard for | |
| 5 * an indexed database. | |
| 6 * By storing data on the client in an IndexedDB, | |
| 7 * a web app gets some advantages, such as faster performance and persistence. | |
| 8 * To find out which browsers support IndexedDB, | |
| 9 * refer to [Can I Use?](http://caniuse.com/#feat=indexeddb) | |
| 10 * | |
| 11 * In IndexedDB, each record is identified by a unique index or key, | |
| 12 * making data retrieval speedy. | |
| 13 * You can store structured data, | |
| 14 * such as images, arrays, and maps using IndexedDB. | |
| 15 * The standard does not specify size limits for individual data items | |
| 16 * or for the database itself, but browsers may impose storage limits. | |
| 17 * | |
| 18 * ## Using indexed_db | |
| 19 * | |
| 20 * The classes in this library provide an interface | |
| 21 * to the browser's IndexedDB, if it has one. | |
| 22 * To use this library in your code: | |
| 23 * | |
| 24 * import 'dart:indexed_db'; | |
| 25 * | |
| 26 * A web app can determine if the browser supports | |
| 27 * IndexedDB with [IdbFactory.supported]: | |
| 28 * | |
| 29 * if (IdbFactory.supported) | |
| 30 * // Use indexeddb. | |
| 31 * else | |
| 32 * // Find an alternative. | |
| 33 * | |
| 34 * Access to the browser's IndexedDB is provided by the app's top-level | |
| 35 * [Window] object, which your code can refer to with `window.indexedDB`. | |
| 36 * So, for example, | |
| 37 * here's how to use window.indexedDB to open a database: | |
| 38 * | |
| 39 * Future open() { | |
| 40 * return window.indexedDB.open('myIndexedDB', | |
| 41 * version: 1, | |
| 42 * onUpgradeNeeded: _initializeDatabase) | |
| 43 * .then(_loadFromDB); | |
| 44 * } | |
| 45 * void _initializeDatabase(VersionChangeEvent e) { | |
| 46 * ... | |
| 47 * } | |
| 48 * Future _loadFromDB(Database db) { | |
| 49 * ... | |
| 50 * } | |
| 51 * | |
| 52 * | |
| 53 * All data in an IndexedDB is stored within an [ObjectStore]. | |
| 54 * To manipulate the database use [Transaction]s. | |
| 55 * | |
| 56 * ## Other resources | |
| 57 * | |
| 58 * Other options for client-side data storage include: | |
| 59 * | |
| 60 * * [Window.localStorage]—a | |
| 61 * basic mechanism in which data is stored as a [Map]. | |
|
sethladd
2013/09/03 18:46:18
might want to mention that localStorage only store
mem
2013/09/03 20:24:02
Done.
| |
| 62 * | |
| 63 * * [dart:web_sql]—a database that can be queried with SQL. | |
| 64 * | |
| 65 * * The [Lawndart](http://pub.dartlang.org/packages/lawndart) package, | |
|
sethladd
2013/09/03 18:46:18
This is cool, but I think we should omit. It's not
mem
2013/09/03 20:24:02
Done.
| |
| 66 * which helps you deal with the wide array of client-side storage options. | |
| 67 * | |
| 68 * For a tutorial about using the indexed_db library with Dart, | |
| 69 * check out | |
| 70 * [Use IndexedDB](http://www.dartlang.org/docs/tutorials/indexeddb/). | |
| 71 * | |
| 72 * [IndexedDB reference](http://docs.webplatform.org/wiki/apis/indexeddb) | |
| 73 * provides wiki-style docs about indexedDB | |
| 74 */ | |
| 1 library dart.dom.indexed_db; | 75 library dart.dom.indexed_db; |
| 2 | 76 |
| 3 import 'dart:async'; | 77 import 'dart:async'; |
| 4 import 'dart:html'; | 78 import 'dart:html'; |
| 5 import 'dart:html_common'; | 79 import 'dart:html_common'; |
| 6 import 'dart:typed_data'; | 80 import 'dart:typed_data'; |
| 7 import 'dart:_js_helper' show Creates, Returns, JSName, Null; | 81 import 'dart:_js_helper' show Creates, Returns, JSName, Null; |
| 8 import 'dart:_foreign_helper' show JS; | 82 import 'dart:_foreign_helper' show JS; |
| 9 import 'dart:_interceptors' show Interceptor, JSExtendableArray; | 83 import 'dart:_interceptors' show Interceptor, JSExtendableArray; |
| 10 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 84 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| (...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1249 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1323 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 1250 // for details. All rights reserved. Use of this source code is governed by a | 1324 // for details. All rights reserved. Use of this source code is governed by a |
| 1251 // BSD-style license that can be found in the LICENSE file. | 1325 // BSD-style license that can be found in the LICENSE file. |
| 1252 | 1326 |
| 1253 | 1327 |
| 1254 @DocsEditable() | 1328 @DocsEditable() |
| 1255 @DomName('IDBAny') | 1329 @DomName('IDBAny') |
| 1256 @deprecated // nonstandard | 1330 @deprecated // nonstandard |
| 1257 abstract class _IDBAny extends Interceptor native "IDBAny" { | 1331 abstract class _IDBAny extends Interceptor native "IDBAny" { |
| 1258 } | 1332 } |
| OLD | NEW |