idb_shim 1.7.2+3
idb_shim: ^1.7.2+3 copied to clipboard

outdated

indexed_db dart polyfill over native, websql, file io or memory implementation

example/example.dart

import 'package:idb_shim/idb.dart';
import 'package:idb_shim/idb_io.dart';

void main() async {
  IdbFactory idbFactory = getIdbPersistentFactory('test/tmp/out');

  // define the store name
  const String storeName = "records";

  // open the database
  Database db = await idbFactory.open("my_records.db", version: 1,
      onUpgradeNeeded: (VersionChangeEvent event) {
    Database db = event.database;
    // create the store
    db.createObjectStore(storeName, autoIncrement: true);
  });

  // put some data
  var txn = db.transaction(storeName, "readwrite");
  var store = txn.objectStore(storeName);
  var key = await store.put({"some": "data"});
  await txn.completed;

  // read some data
  txn = db.transaction(storeName, "readonly");
  store = txn.objectStore(storeName);
  final value = await store.getObject(key) as Map;
  await txn.completed;

  print(value);
}
10
likes
0
pub points
93%
popularity

Publisher

tekartik.com

indexed_db dart polyfill over native, websql, file io or memory implementation

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

collection, js, path, sembast

More

Packages that depend on idb_shim