reservoir 1.4.0 copy "reservoir: ^1.4.0" to clipboard
reservoir: ^1.4.0 copied to clipboard

An indexed table-like data type that works well with Hive boxes.

A table-like datatype with indices. Works well with HiveDB.

Usage #

A simple usage example:

import 'package:equatable/equatable.dart';
import 'package:reservoir/reservoir.dart';

class User with EquatableMixin {
  final String id;
  final String name;
  final String status;
  User(this.id, this.name, this.status);

  @override
  List<Object?> get props => [id];

  @override
  String toString() => 'User($id, $name, $status)';
}

class UserReservoir extends Reservoir<String, User> {
  late IndexMultiple byStatus;

  UserReservoir(Source<String, User> source, GetKey<String, User> getKey)
      : super(source, getKey) {
    byStatus = addIndexMultiple('status', (user) => user.status);
  }
}

void main() async {
  var source = MapSource<String, User>();
  var res = UserReservoir(source, (User user) => user.id);
  await res.save(User('1', 'John', 'active'));
  await res.save(User('2', 'Shawna', 'active'));
  await res.save(User('3', 'Meili', 'inactive'));
  print(res.byStatus.getAll('active'));
  // => (User(1, John, active), User(2, Shawna, active))
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

0
likes
95
pub points
0%
popularity

Publisher

unverified uploader

An indexed table-like data type that works well with Hive boxes.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

collection, equatable, hive, ordered_set, rxdart

More

Packages that depend on reservoir