GithubHelp home page GithubHelp logo

hieunc229 / clientdb.js Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 1.0 295 KB

A Reactive and Minimalistic Interface for IndexedDB with Promises (TypeScript supported)

License: Other

TypeScript 38.50% JavaScript 58.97% HTML 0.93% CSS 1.60%
client-database browser-database localstorage indexeddb indexeddb-wrapper typescript

clientdb.js's Introduction

ClientDB.js

A Reactive and Minimalistic Interface for IndexedDB with Promises (TypeScript supported)

Table of contents:

More on Wiki page:

1. Introduction

IndexedDB is an in-browser database with slightly more advantages than other in-browser databases. For example more storage space, support more complex data structure. Although it APIs are complex to use.

ClientDB.js is a wrapper for IndexedDB with simple APIs, all requests return a promise.

Features:

  • ✅ Basic CRUD (create, read, update, delete) data records backed by sophisticated IndexedDB
  • ✅ Filter data using keys/indices
  • ✅ Event subscribers (subscribe event when insert, remove, and update)
  • TODO: paging, limit, relationship

2. Quickstart

var stores = [{
    name: "Users",
    keys: {
        firstName: false,
        lastName: false,
        username: true
    }
}]

var myDB = new ClientDB({ stores });

// Insert
myDB.collect("Users").insert({
    _id: 'your_own_id', // auto 
    firstName: 'Peter',
    lastName: 'Griffin',
    username: 'peter_grif' // is unique
})
.then(({ items, changes}) => {
    
    // items => Array(1) => [{ added record }]
    // changes => { inserted: 1, removed: 0, updated: 0, unchage: 0 }
})
.catch(error => {

    // error => { message }
})

3. Installation

ClientDB.js is available as npm module (supported TypeScript) and also works with plain Javascript. Follow one of the instructions below to install ClientDB.js to your project

Install as NPM Module

$ npm install --save clientdb.js

Then import ClientDB into your project

import ClientDB from 'clientdb.js';

Install as In-browser Javascript Library

// replace @x.x.x with current version
// Available through window.ClientDB or just ClientDB
<script src="https://unpkg.com/[email protected]/dist/ClientDB.js"></script>

You can find API References, Build and Tests section on ClientDB.js Wiki Page. And feel free to create an issue related to this project or need any help.

clientdb.js's People

Contributors

hieunc229 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

pwfoo

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.