Coder Social home page Coder Social logo

isar-crdt's Introduction

Isar CRDT

ci

⚠️ WIP ⚠️

This project aims to extend the functionality of the Isar database to allow remote synchronization (isar/isar#2).

The remote synchronization is achieved by generating HLC (Hybrid Logical Clock) per field that act as a version number for the current value. This allows two versions of an object to be merged consistently while also retaining the newer version of each field.

Synchronization types support

  • collection classes
  • embedded classes
  • primitive types
  • Lists

Usage

import 'package:isar_crdt/isar_crdt.dart'; //  <-- 
import 'package:isar/isar.dart';

part 'test_class.isar_crdt.g.dart'; //  <-- 
part 'test_class.isar.g.dart'; // <-- instead of test_class.g.dart

@crdtCollection //  <-- 
@collection
class TestClass extends _TestClassCrdt {
    ...
}

...

// Create/update object
await isar.writeTxn(() {
    return isar.testClass.put(obj);
});

// Merge object from a remote node
await isar.writeTxn(() {
    return isar.testClass.merge(obj);
});

isar.testClass return IsarCrdtCollection (instead of IsarCollection) that abstract all the HLC handling logic.

Limitations

to generate globally unique IDs for isar objects the following limitations are recommended to avoid ID collisions.

  1. 4,294,967,295 objects per Isar collection.
  2. 4,294,967,295 nodes or users.

isar-crdt's People

Contributors

kerero avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.