Features

DreamyOptions : Object

The options for Dreamy-db.

new Dreamy( options = { } )

Parameters

  • options : string| DreamyOptions

Properties

uri : string

The connection URI of the database.

namespace : string

The namespace of the database.

The storage adapter or backend to use.

  • store : *

The options for Dreamy.

A data serialization function.

A data deserialization function.

The name of the collection. Only works for MongoDB.

The name of the table. Only works for SQL databases.

The maximum size of the keys of elements.

Example:

These Options are optional only.

Namespaces

Namespaces isolate elements within the database to avoid key collisions, separate elements by prefixing the keys, and allow clearance of only one namespace while utilizing the same database.

Third-Party Adapters

You can optionally utilize third-party storage adapters or build your own. Dreamy-db will integrate the third-party storage adapter and handle complex data types internally.

For example, quick-lru is an unrelated and independent module that has an API similar to that of Dreamy-db.

Custom Serializers

Dreamy-db handles all the JSON data types including Buffer using its data serialization methods that encode Buffer data as a base64-encoded string, and decode JSON objects which contain buffer-like data, either as arrays of strings or numbers, into Buffer instances to ensure consistency across various backends.

Optionally, pass your own data serialization methods to support extra data types.

Embeddable

Dreamy-db is designed to be easily embeddable inside modules. It is recommended to set a namespace for the module.

Last updated

Was this helpful?