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

Support library for Nitrite database to provide some additional features like encryption, import/export database etc.

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
140
pub points
0%
popularity

Publisher

verified publisherdizitart.com

Support library for Nitrite database to provide some additional features like encryption, import/export database etc.

Homepage
Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

Funding

Consider supporting this project:

github.com

License

Apache-2.0 (LICENSE)

Dependencies

compute, convert, encrypt, nitrite, path

More

Packages that depend on nitrite_support