My First Rust Application — Meet Mjolnir chained database

Alfiankan
3 min readMar 11, 2022
  • Mjolnir is chained data database inspired by block chain chaining block

Conceptual :

chained data
  • we using sha256 to hash data.
  • every box data is chained, will decrease fraud posibility.
  • i think is suitable for storing medical records, or ownership records or other data.
  • data is a string, you can store json string to it

How To install

using homebrew (for simple installation step) :

  • add tap
brew tap alfiankan/mjolnir
  • then install
brew install mjolnir

How to build from source

  • make sure you have rustup
  • clone this repository on master branch
  • then build
 cargo build — all-targets — release
  • movemjolnir binary to bin directory
sudo cp target/release/mjolnir /usr/local/bin/

Terms

  • Box : Box is imaginary block or Box conatins prev hash, data, and hash :
Box contains prev hash, data and hashed data
  • Genesis : genesis is process to make first Box with singularity hash, singularity hash is just random hash generated
  • Chain : is relationship between box using hash :
chain match hash
  • record : is all data box with chain relationship from one genesis :
record contain boxes with chain

How to use

  • make sure mjolnir installed
  • create text file for data store
  • set store file location by setting up environment variable
export MJL_DATA_STORE=/path/to/mjfile/database.mj
  • open mjolnir cli by typing `mjolnir` in terminal

MJL (Mjolnir query language)

Genesis :

  • to make new record you need genesis to do that type gen
  • then you get the key chain, save it

records :

  • mjolnir support multiple records, to make another record just run genesis, to list all records type records

Insert :

  • to insert box (next box) you can do insert to <record key_chain> '<string data>'

Select :

  • to get last record data do select <record key_chain>

Select All :

- to get all box with chains record data do select <record key_chain> all

Appendix :

--

--

Alfiankan

Lifetime learner | Backend Engineer at Soul Parking