Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lpil/storail
https://github.com/lpil/storail
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/lpil/storail
- Owner: lpil
- Created: 2024-10-19T13:59:13.000Z (24 days ago)
- Default Branch: main
- Last Pushed: 2024-10-21T17:03:50.000Z (22 days ago)
- Last Synced: 2024-10-22T04:43:17.828Z (22 days ago)
- Language: Gleam
- Size: 8.79 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-gleam - storail - [π](https://hexdocs.pm/storail/) - A simple on-disc JSON based data store (Packages / Databases)
README
# StΓ³rΓ‘il
A simple on-disc JSON based data store.
[![Package Version](https://img.shields.io/hexpm/v/storail)](https://hex.pm/packages/storail)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/storail/)A super basic on-disc data store that uses JSON files to persist data.
It doesn't have transactions, MVCC, or anything like that. It's just
writing files to disc. Useful for tiny little projects, and for fun.```sh
gleam add storail@1
```
```gleam
import storail
import my_apppub fn main() {
// Construct config to specify where your data is written to.
let config = storail.Config(
data_directory: "/data",
temporary_directory: "/tmp/storail",
)// Define a collection for a data type in your application.
let cats = storail.Collection(
name: "cats",
to_json: my_app.cat_to_json,
decoder: my_app.cat_decoder,
config:,
)// A key points to a specific object within the collection, which
// may or may not yet exist.
let key = storail.key(collection, "nubi")// Write some data
let assert Ok(Nil) = storail.write(key, my_app.Cat("Nubi", 5))// Read some data
storail.read(key)
// -> Ok(my_app.Cat("Nubi", 5))
}
```Further documentation can be found at .