0.1.5 • Published 4 years ago
esm-db v0.1.5
esm-db
An asynchronous data structure database using JavaScript ES modules
npm i esm-db
Quick start
Node
import t from '@babel/types'
import {record, array, set, sortedSet} from 'esm-db'
// Use the database
const db = record({
root: 'path/to/posts',
plugins: [injectDependencies],
schema: {
title: t.stringLiteral,
},
})
await db.get('my-post')
await db.put('my-post', someData)
await db.put(id, someData)
await db.delete('my-post')
const otherDb = array({
root: 'path/to/tags',
plugins: [],
presets: [],
type: t.stringLiteral,
})
otherDb.push('foo')
otherDb.delete('foo')
otherDb.includes('foo')
otherDb.length()
const otherDb = set('tags', t.stringLiteral)
otherDb.add('foo')
otherDb.delete('foo')
otherDb.has('foo')
otherDb.size()
const otherDbAgain = sortedSet('tags', t.stringLiteral)
otherDb.add('foo')
otherDb.incrBy('foo', 1)
otherDb.incrBy('foo', -1)
otherDb.delete('foo')
otherDb.has('foo')
otherDb.size()
Web
import {record} from 'esm-db/web'
const db = record('blogPost')
db.get(13)
API
put()
Arguments
Name | Type | Default | Required? | Description |
---|---|---|---|---|
LICENSE
MIT