Features
DreamyOptions : Object
Object
The options for Dreamy-db.
new Dreamy( options = { } )
new Dreamy( options = { } )
Parameters
options
:string
| DreamyOptions
Properties
uri
: string
uri
: string
The connection URI of the database.
namespace
: string
The namespace of the database.
adapter
:string
The storage adapter or backend to use.
store
:*
The options for Dreamy.
serialize
:function
A data serialization function.
deserialize
:function
A data deserialization function.
collection
:string
The name of the collection. Only works for MongoDB.
table
:string
The name of the table. Only works for SQL databases.
keySize
:number
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.
Using custom serializers means you lose any guarantee of data consistency.
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?