@directdb/yaml-handler v0.5.0
@directdb/yaml-handler
YAML file handler for DirectDB.
This handler uses the library yaml
under the hood, because it preserves comments unlike other YAML libraries. It defaults to YAML spec 1.2.
Version 2 of the yaml
library is under active development and the documentation defaults to version 2. Be sure to refer to the version 1 documentation instead.
Install
npm i @directdb/yaml-handler
# OR
yarn add @directdb/yaml-handler
Usage
The main package directdb
already includes @directdb/yaml-handler
.
If you want to create your own variant of DirectDB with this handler, you can compose one with @directdb/core
:
import directdb from '@directdb/core'
import yamlHandler from '@directdb/yaml-handler'
const db = await directdb('.', { fileHandlers: [yamlHandler] })
Options
Options are directly passed to yaml
's parse and stringify methods. See the yaml
library docs for full options.
Customize your file handler options like so:
import directdb from 'directdb'
import yamlHandler from '@directdb/yaml-handler'
yamlHandler.options = {
prettyErrors: true,
}
const db = await directdb({ fileHandlers: [yamlHandler] })
Options Type Definition
The package exports the TypeScript type interface of this options object. In .ts
files you can import this type as a helper for constructing the options object:
import * as YamlHandler from '@directdb/yaml-handler'
const options: YamlHandler.Options = {
/* options*/
}