@xplive/synceddb
TypeScript icon, indicating that this package has built-in type declarations

1.0.19 • Public • Published
Synceddb

 

Synceddb

Github top language Github language count Repository size License


About   |   Technologies   |   Requirements   |   Getting started   |   License   |   Author


About

Client-side CRUD operations between indexedDB and a server.

Technologies

The following tools were used in this project:

  • idbx - an indexedDB wrapper

Getting started

import * as idbx from "https://deno.land/x/idbx/main.ts";
import { SyncedDB } from "https://deno.land/x/synceddb/main.ts";

// create a database
const dbreq = idbx.open('my-database', 1);

// create a store
dbreq.upgrade((event) => {
  const target = event.target as IDBOpenDBRequest;
  const db = target.result;
  SyncedDB.createStore(db, "mystore");
});

// wait for DB to initialize
const db = await dbreq.ready;

// create a synceddb instance
const syncdb = new SyncedDB(db, "mystore", {
keyName: "id",
  // Default Settings:
  
  // url: location.origin,
  // autoSync: false,
  // createPath: "/api/create",
  // readPath: "/api/read",
  // updatePath: "/api/update",
  // deletePath: "/api/delete",
  // readAllPath: "/api/read_all",
  // syncPath: "/api/sync",
});

const result = await syncdb.create({
  title: "Awesome!",
  description: "Probably a reinvention of the wheel ;-P"
});
// case 1 (online): writes entry into the indexedDB store and send the entry to the server
//                  sync_action: "none", sync_status: "synced"
// case 2 (offline): writes entry into the indexedDB store and creates a temporary ID
//                  sync_action: "create", sync_status: "unsynced"

License

This project is under license from MIT. For more details, see the LICENSE file.

Made by Mario Stöcklein

 

Back to top

Readme

Keywords

none

Package Sidebar

Install

npm i @xplive/synceddb

Weekly Downloads

1

Version

1.0.19

License

MIT

Unpacked Size

102 kB

Total Files

26

Last publish

Collaborators

  • mstoecklein