Absurd
A command line tool for managing stores in Surreal DB.
Installation
Absurd is available on crates.io, and requires that you also have cargo installed.
That's it!
Usage
Absurd should be run within the root of your project.
Running absurd -h will display the following output.
)
A component is one of Controller, Model, or Store.
You can think of these components as the following:
ControllerControllers are a layer in between your models and storesModelModels represents any record from the storeStoreStores handles the connection to a database
Usage Examples
Create a new store
Currently there is only support for the Mem and RocksDB engines.
In the future, we plan to add support for all available SurrealDB engines including Ws.
# Create a store called General, using the Mem engine.
# This creates an in memory store, where no data is persisted.
# Create a store called Setting, that stores the data in a file.
Create a new model
Models are a way to map your database records to a Rust struct.
There are two available table schemas available in SurrealDB: Schemaless and Schemafull.
By default, Schemafull will be selected, unless the model name is passed like Setting/Dark without any --fields.
A Schemafull table will be a single struct, where each field is a property of the struct.
A Schemaless table will be a struct with a single field, where the value is a map of the record.
All models will be given the id with the type Option<Thing>.
This is set to optional as it makes it easier to create new records without having to create a new struct.
# All fields will be given the data type of String. Support may be added to set
# the data type in the CLI.
# Creates a Schemafull model called User, with the fields name and email.
# User { id: Option<Thing>, name: String, email: String }
# Create a Schemaless model called Setting, with the fields name and value.
# SettingDark { id: Option<Thing>, name: String, value: String }