sembast_web 2.0.1 copy "sembast_web: ^2.0.1" to clipboard
sembast_web: ^2.0.1 copied to clipboard

outdated

NoSQL persistent embedded database for the Web on top of IndexedDB

Sembast for the web #

sembast for the Web, NoSQL persistent embedded database for the Web on top of IndexedDB.

Works on browser applications and flutter web applications.

Setup #

In pubspec.yaml

dependencies:
  sembast_web: '>=1.0.0'

Usage #

import 'package:sembast/sembast.dart';
import 'package:sembast_web/sembast_web.dart';

Future main() async {
  // Declare our store (records are mapd, ids are ints)
  var store = intMapStoreFactory.store();
  var factory = databaseFactoryWeb;

  // Open the database
  var db = await factory.openDatabase('test');

  // Add a new record
  var key =
      await store.add(db, <String, Object?>{'name': 'Table', 'price': 15});

  // Read the record
  var value = await store.record(key).get(db);

  // Print the value
  print(value);

  // Close the database
  await db.close();
}

Features and limitations #

  • Use int or key string only
  • Content is synchronized across all open tabs
  • Transactions are cross-tab safe (since 0.1.0+4)
  • Codec are not supported. Web is not safe anyway. Encrypt fields as needed.
  • Transactions must be idempotent (i.e. they must produce the same result if run twice) as they might run again in case of concurrent access.

How it works #

Like sembast the whole database is loaded into memory from indexedDB. It notifies cross tabs using localStorage. data is incrementally updated from indexedDB. If a transaction is ran after some changes happens, new data is loaded and transaction is ran again.

The only exported API is databaseFactoryWeb. For more information on the API see sembast documentation.

55
likes
0
pub points
97%
popularity

Publisher

verified publishertekartik.com

NoSQL persistent embedded database for the Web on top of IndexedDB

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

idb_shim, sembast

More

Packages that depend on sembast_web