0.0.14 • Published 12 months ago

zeneithdb v0.0.14

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

This is a simple library for interacting with indexDB.

It keeps tracks of databases for you and makes it easy to upgrade and delete databases as well as do basic CRUD operations.

import { ZeneithDB } from "ZeneithDB";
import type { DataBase, ZeneithDatabaseCreationData } from "ZeneithDB";
(async () => {
 await ZeneithDB.$INIT();
 const dbName = "zeneith-example-one";
 const dbData: ZeneithDatabaseCreationData = {
  databaseName: dbName,
  collections: [
   {
    name: "collection1",
    schema: [
     {
      name: "id",
      valueType: "string",
      index: true,
      isUnique: true,
     },
    ],
   },
  ],
 };
 const existanceCheck = await ZeneithDB.databaseExists(dbName);
 let database: DataBase;
 if (!existanceCheck) {
  database = await ZeneithDB.createDatabase(dbData);
 } else {
  database = await ZeneithDB.getDatabase(dbName);
 }
 await database.open();
 await database.setData("collection1", "test-1", {
  data1: {
   key: "1",
  },
  data2: {
   key: "2",
  },
 });
 const data = await database.getData("collection1", "test-1");
 document.body.innerText = JSON.stringify(data, undefined, 4);
 database.close();
})();
0.0.10

12 months ago

0.0.12

12 months ago

0.0.14

12 months ago

0.0.9

12 months ago

0.0.8

12 months ago

0.0.5

12 months ago

0.0.7

12 months ago

0.0.6

12 months ago

0.0.3

12 months ago

0.0.21

1 year ago

0.0.2

1 year ago

0.0.22

1 year ago

0.0.23

1 year ago

0.0.1

2 years ago

0.0.0

2 years ago