Skip to content
This repository was archived by the owner on Apr 11, 2019. It is now read-only.

oprogramador/js-abstract-synchronizer

Repository files navigation

js-abstract-synchronizer

MIT License Build Status

NPM status

This library is no longer supported, please use vinberodb instead.

This library works on:

  • backend like ODM or ORM
  • frontend making HTTP requests to save data on the server

install

npm install --save js-abstract-synchronizer

usage

import arangojs from 'arangojs';
import { SerializerFactory } from 'js-abstract-synchronizer';

const db = arangojs({ url: 'http//user:password@localhost:8529' });

class Person {
  constructor({ id, name, surname }) {
    this.id = id;
    this.name = name;
    this.surname = surname;
  }
  getName() {
    return this.name;
  }
  getSurname() {
    return this.surname;
  }
  setName(name) {
    this.name = name;
  }
  setSurname(surname) {
    this.surname = surname;
  }
}
const serializer = SerializerFactory.create({
  implementationName: 'ArangoSerializer',
  implementationParams: {
    db,
  },
  prototypes: {
    Person: Person.prototype,
  },
});

const alicia = serializer.create(new Person({ name: 'alicia', surname: 'aaa', id: 'foo' }));
const newAlice = serializer.create({ id: 'foo' });

export default serializer.configure('database-name')
  .then(() => alicia.save())
  .then(() => console.log(alicia.getName()))
  .then(() => newAlice.reload())
  .then(() => console.log(newAlice.getName()))
});

About

Data synchronizer between database, backend and frontend

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •