0.5.1 • Published 4 years ago

directdb v0.5.1

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

šŸ—‚ļø DirectDB

NPM GitHub Workflow Status Node.js Versions

Turn a directory into a database. Store data in folders and human-readable files like YAML, Markdown, and JSON.

Still in development. Expect breaking changes.

Install

npm i directdb
# or
yarn add directdb

Getting Started

import directdb from 'directdb'

const rootDir = '.' // Relative or absolute path to a directory
const db = await directdb(rootDir)

// $ is an alias for the root directory
await db.cache.dir['$'] // get details about the root directory
await db.cache.file['$/some/file.json'] // get file details w/ parsed content

// CRUD methods; they update the caches too
await db.createFile('$/foo.yaml', ['some', 'data'])
await db.readFile('$/foo.txt') // reads file cache
await db.updateFile('$/foo.yaml', ['updated', 'data'])
await db.removeFile('$/foo.md')

await db.createDir('$/some/dir')
await db.readDir('$/some/dir') // reads dir cache
await db.removeDir('$/some/dir')

// search caches w/ plain JS
const results = Object.values(db.files).filter((fileDetails) =>
  fileDetails.contents.contains('Some Search String')
)

JSON, YAML, and Markdown w/ YAML front matter

db.file('$/foo.json').content // { some: ['data'] }
db.file('$/foo.yaml').content // { yaml: ['data'] }
db.file('$/foo.md').content // { markdown: "# Hello!", frontMatter: {} }

Optional JSON Schema Validation

$/
ā”œā”€ .schema.json   // files in the folder will be validated against this
ā”œā”€ someData.json
ā”œā”€ moreData.yaml
└─ fileWithYamlFrontMatter.md

Docs

See local markdown docs, including:

Examples and Cookbook

Coming soon!

0.5.0

4 years ago

0.5.1

4 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0-test

4 years ago

0.1.0

4 years ago