Skip to content

zediculz/danych

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Danych

Danych is a 1kb lightweight database in the browser. Danych is simply a Browser Storage built on top of localStorage and sessionStorage.

Installation

  npm i danych
import useDanych from "danych"

interface Todo {
  id: number
  text: string
}

//Starting with full config
const db = useDanych.init<Todo>({
  key: "my-app-data",
  type: "session"
})

//OR, start localStorage with just the key
const db = useDanych.db("my-database-key")

//OR, start sessionStorage with just the key
const db = useDanych.state("my-database-key")

call init() to start Danych with either full config object.

call db() to start Danych with localStorage with just Db Key.

call state() to start Danych with sessionStorage with just Db Key.

Danych treats all the datas like a collection which makes the DefaultData an Array by Default.

Usage

Storing Data

store new data using Danych.

//set new data
db.set({ id: 1, text: "some data" })

//set data with id
db.set({ id: 1, text: "some data" }, 0)

Getting Data

get all the datas or get data with id.

//get all the store datas
const datas = db.get()

//get data with id
const datas = db.get(1)

Updating Data

//update data with id
db.update({ id: 64, text: "new data value" }, 1)

Removing Data

//remove data with id
db.remove(0)

//remove last stored data
db.remove()

Properties

  • datas - return all store datas.

###Danych is 750 Bytes, Fast, Fully Typed and Lightweight 🚀💨

NPM

JavaScript Style Guide

Contact

License

MIT ©

About

a 1kb lightweight database in the browser built on top of localStorage and sessionStorage

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published