Skip to content

ad-si/ybdb

Repository files navigation

YBDB

YAML Based Database

Uses lowdb for accessing and manipulating data. The storage consists of one/several YAML files.

Installation

npm install --save ybdb

Usage

songs.yaml:

- title: Song One
  length: 02:16

- title: Another Song
  length: 01:33

- title: The Song
  length: 03:41
import path from "node:path"
import { fileURLToPath } from "node:url"
import Ybdb from "ybdb"

const __dirname = path.dirname(fileURLToPath(import.meta.url))

const database = new Ybdb({
  storageFile: path.join(__dirname, "songs.yaml"),
})
const initializedDb = await database.init()
const expectedData = {
  songs: [
    {
      title: 'Song One',
      length: '02:16',
    },
    {
      title: 'Another Song',
      length: '01:33',
    },
    {
      title: 'The Song',
      length: '03:41',
    }
  ]
}

assert.deepEqual(initializedDb.data, expectedData)

This package is ESM-only and ships with TypeScript types.

About

YAML Based Database

Topics

Resources

Stars

8 stars

Watchers

1 watching

Forks

Contributors