Hello everyone! I’m proud to announce my first opam package: SandDB
SandDB is a simple immutable database that I made, because I couldn’t really find a dead simple database (like TinyDB) for Ocaml and also because it’s fun to reinvent the wheel.
SandDB is exciting, because it’s:
- Simple: The code base is small and the db is easy to get started with. The basic building block of the database is also pretty simple, which is the record. A record consist only two element: id element(which is basically a randomly generated uuid) and data element, whose type you can define with atd.
- Flexible: You can define your own record data type with atd, which also means that you can create both a json and biniou database thanks to atdgen.
- Immutable: SandDB is built on the basic idea that it should be like an immutable stack, where you can only push elements. It’s implemented just by using file appended write, so SandDB is closer to a logger than a classical database.
- Crud capable: Even though it’s an immutable database you still can update and delete records thanks to the shadowing insert, which works by using the old record’s id for the new updated or deleted record. The basic idea here was the let binding in Ocaml, which can also shadow another let binding if it has the same name.
- Asynchronous: File operations are dead slow compared to others, so it was important that the db was async.
- Error tolerant: Every commonly dangerous operation like parsing is covered by Result, so you can expect where things can go south.
I have to thank the developers and maintainers of atdgen,lwt,uuidm and base, because without them I couldn’t really have done this.
Next steps:
- Using standard module naming(My_module) instead of my(My_Module).
- Maybe adding lwt stream to the database so the range of the read could be controlled.
- Start working on the next small project