Skip to content

davidlondono/isar_crdt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Isar Crdt

addon to add crdt capabilities to isar

Features

  • Pure Dart
  • Save changes on collection

Getting started

1. Add to pubspec.yaml

dependencies:
  isar_crdt: ^0.0.1

Usage

  1. extend your models with CrdtBaseObject
  • add toJson function and add all the fields you want to sync (include id and sid)
  1. Create a model to store the crdt changes and extends with ChangesyncBaseModel
  • no need to add anything
// models
@collection
class CarModel extends CrdtBaseObject {
  Id id = Isar.autoIncrement;
  late String make;
  late String year;

  @override
  Map<String, dynamic> toJson() {
    return {
      "id": id,
      "sid": sid,
      "make": make,
      "year": year,
    };
  }
}

@collection
class CrdtEntry extends ChangesyncBaseModel {}
  1. add the models including the crdt model to the isar instance
  2. create a changesync instance and add it to the isar instance
  final isar = await Isar.open(
      [CarModelSchema, CrdtEntrySchema],
    );


  final changesSync = IsarCrdt(
    store: IsarMasterCrdtStore(
      isar.crdtEntrys,
      builder: () => CrdtEntry(),
      sidGenerator: () => uuid.v4(),
    ),
  );
  isar.setCrdt(changesSync);

Additional information

TODO: Tell users more about the package: where to find more information, how to contribute to the package, how to file issues, what response they can expect from the package authors, and more.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages