npm.io
0.5.3 • Published 5 years ago

@ashikuri/table-db

Licence
ISC
Version
0.5.3
Deps
3
Size
488 kB
Vulns
0
Weekly
0

table-db

Tiny database interfacer

Install

$ npm i @ashikuri/table-db
or
$ yarn add @ashikuri/table-db

Usage

import TableApp from "@ashikuri/table-db"
import { JSONAdapter } from "@ashikuri/table-db/adapters"

async function application(){
    const db = new TableApp("./database.json", JSONAdapter)
    const users = await db.collection("users")

    // return users
    await users.insert({
        id: 0,
        name: "John Doe",
        email: "john@doe.com",
        online: true
    }, {
        id: 1,
        name: "John Doe 2",
        email: "john2@doe.com",
        online: false
    })
    // ...
    // note: Collection.save is an alias as db.save
    await users.save() // or db.save() or db.write()
}
application()