Storage engines
The heart of Tashmet
Introduction
The storage engine is responsible for storing documents. It is bundled with an aggregation engine that allows for queries such as finding, updating, replacing and deleting those documents.
Nabu
The primary storage engine for Tashmet is called Nabu. It is a persistent storage solution that allows for documents to be written to and read from the file system. Nabu is also bundled with a fallback option for in-memory storage that is used by default.
Features
Persistent file storage
Built in support for JSON, YAML and Markdown
Available only in server (Node.js)
Includes fallback in-memory storage option
Configuration
The following example creates a Nabu storage engine with default configuration, using mingo as aggregation engine.
See the Hello world example for how to connect to and operate on the store
One important aspect of Nabu is that the state of the databases, ie which collections they have and how they are set up, can be persisted to disk in human readable form. If you don't need to create databases and collections dynamically at runtime it's probably more convenient to just craft a configuration file by hand in yaml.
The following configuration option will tell Nabu to look up a database configuration in a yaml file with the same name as the database.
Let's create the configuration file for a database called mydb that should have a collection named posts. We're using a directory to store our documents. For more details and other options see storage options below.
To connect to our database and use the collection we simply do the following.
Storage options
Nabu supports a wide range of different storage options that determine how documents are read from and written to disk.
These can be configured per collection or be specified for the whole database
Memory
The memory storage engine is a purely volatile storage solution.
Features
Volatile In-memory storage
Available both on server and in browser
For each supported operation the Tashmet client will build a command that is passed through a proxy, either the proxy provided by the storage engine, or though a network connection to a server that acts on the storage engine.
Hence, once a storage engine is created, we can actually execute these raw commands on the engine directly. Consider the following example:
Last updated
Was this helpful?