# leandb

> ES6 indexedDB library

Latest version **1.0.8** (published 2019-02-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install leandb
pnpm add leandb
yarn add leandb
bun add leandb
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2019-02-02 |
| First published | 2019-01-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 19.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | tonis |
| Maintainers | tonis2 |

## Links

- npm: https://www.npmjs.com/package/leandb
- Repository: https://github.com/tonis2/LeanDB
- Homepage: https://github.com/tonis2/LeanDB#readme
- Issues: https://github.com/tonis2/LeanDB/issues
- npm.io page: https://npm.io/package/leandb

## Recent versions

- 1.0.8 (latest) — 2019-02-02
- 1.0.7 — 2019-02-02
- 1.0.6 — 2019-02-02
- 1.0.5 — 2019-01-20
- 1.0.4 — 2019-01-19
- 1.0.3 — 2019-01-18
- 1.0.2 — 2019-01-17
- 1.0.1 — 2019-01-10
- 1.0.0 — 2019-01-10

## README

### 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](http://img.badgesize.io/https://unpkg.com/leandb@latest/build/leandb.esm.js?compression=gzip)


#### Add database to your project 

```
npm install leandb --save
```

or in modern browsers


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

```


 #### Initialize

Store properties

* `++` : <strong>Auto incrementation</strong>
* `&` : <strong>Must be unique value</strong>



```JS
const stores = {
  friends: "id++,name&,age",
  notebooks: "id,name,content"
}

const db = new Database("test")

db.init(1, stores)

```


#### Add data

```JS
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

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

```

#### Delete data where query matches

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

#### Find data where query matches

```JS
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 

```JS 
import Database, { query } from "https://unpkg.com/leandb@latest/build/leandb.esm.js"
```

```JS

const params = query`age > ${3}`

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

```

---
_Source: https://npm.io/package/leandb · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
