nitrite_support 1.0.0 copy "nitrite_support: ^1.0.0" to clipboard
nitrite_support: ^1.0.0 copied to clipboard

Support library for Nitrite database.

example/example.dart

import 'package:nitrite/nitrite.dart';
import 'package:nitrite_hive_adapter/nitrite_hive_adapter.dart';
import 'package:nitrite_support/nitrite_support.dart';

void main(List<String> args) async {
  // export the database to a json file
  var exporter = Exporter.withOptions(
    dbFactory: () async {
      var storeModule = HiveModule.withConfig()
          .crashRecovery(true)
          .path('/tmp/old-db')
          .build();

      return Nitrite.builder()
          .loadModule(storeModule)
          .openOrCreate(username: 'user', password: 'pass123');
    },
    collections: ['first'],
    repositories: ['Employee'],
    keyedRepositories: {
      'key': {'Employee'},
    },
  );
  await exporter.exportTo('/tmp/exported.json');

  // import the database from the json file
  var importer = Importer.withOptions(
    dbFactory: () async {
      var storeModule = HiveModule.withConfig()
          .crashRecovery(true)
          .path('/tmp/new-db')
          .build();

      return Nitrite.builder().loadModule(storeModule).openOrCreate();
    },
  );
  await importer.importFrom('/tmp/exported.json');
}
0
likes
0
points
60
downloads

Publisher

verified publisherdizitart.com

Weekly Downloads

Support library for Nitrite database.

Homepage
Repository (GitHub)
View/report issues

Funding

Consider supporting this project:

github.com

License

unknown (license)

Dependencies

compute, convert, encrypt, nitrite, path

More

Packages that depend on nitrite_support