1.0.8 • Published 5 years ago

leandb v1.0.8

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

Lean indexedDB library


Want to use indexedDB in browser but the API seems too hard to manage ?

LeanDB will help you here, it provides easy to use API, small JavaScript footprint and is fully dependency free.

gzip size

Add database to your project

npm install leandb --save

or in modern browsers

import Database from "https://unpkg.com/leandb@latest/build/leandb.esm.js"

Initialize

Store properties

  • ++ : Auto incrementation
  • & : Must be unique value
const stores = {
  friends: "id++,name&,age",
  notebooks: "id,name,content"
}

const db = new Database("test")

db.init(1, stores)

Add data

db.friends.add({ "name": "Steve", age: 5, id: 1 })
db.friends.add({ "name": "Roger", age: 2, id: 2 })

Update data with new value where query matches

db.friends.update({name:"Steve"}).value({age:7}).then(result => {
  console.log(result)
})

Delete data where query matches

db.friends.delete({name: "Roger"})

Find data where query matches

db.friends.search({name:"Roger", age:5}).then(result => {
  console.log(result)
})

const data = await db.friends.find({name:"Steve"})

console.log(data)

Query data

Add query to library requirements

import Database, { query } from "https://unpkg.com/leandb@latest/build/leandb.esm.js"
const params = query`age > ${3}`

db.friends.search(params).then(result => {
  console.log("Age bigger than", result)
})
1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago