Crates.io | absurd |
lib.rs | absurd |
version | 0.2.1 |
source | src |
created_at | 2024-08-18 22:54:25.292595 |
updated_at | 2024-09-13 23:48:21.698641 |
description | Command line tool for managing Surreal stores. |
homepage | https://github.com/BritishWerewolf/absurd |
repository | https://github.com/BritishWerewolf/absurd |
max_upload_size | |
id | 1343147 |
size | 38,310 |
A command line tool for managing stores in Surreal DB.
Absurd is available on crates.io, and requires that you also have cargo installed.
cargo install absurd
That's it!
Absurd should be run within the root of your project.
Running absurd -h
will display the following output.
Command line tool for managing Surreal stores.
Usage: absurd <COMMAND>
Commands:
create Specify which type of component you want to create
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
A component is one of Controller
, Model
, or Store
.
You can think of these components as the following:
Controller
Controllers are a layer in between your models and storesModel
Models represents any record from the storeStore
Stores handles the connection to a databaseCurrently 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.
absurd create store General
absurd create store General --engine mem
# Create a store called Setting, that stores the data in a file.
absurd create store Setting --engine rocks-db
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 }
absurd create model User --fields name email
absurd create model User --fields name email --schemafull
# Create a Schemaless model called Setting, with the fields name and value.
# SettingDark { id: Option<Thing>, name: String, value: String }
absurd create model Setting/Dark
absurd create model Setting --fields dark --schemaless