Motoko Database

Progress update: Well, I was going just to design it, but It was going well, so I almost made it all.
Currently uses Map, BTree and I am thinking of adding Vector. There has to be an option between Map or Vector for the primary key.

Setup:


As you can see, it allows the dev to create indexes and they can dynamically generate them from something like an array of ‘skills’. You can also think of it as searching by tag.

Inserting/updating data:

Queries (These examples provide performance similar to well-indexed SQL)

It’s stable even tho it looks like a Class.
No need to provide <Types> or hashing or comparison when you use it.
Talking about the interface → I believe that’s how libraries should be written unless someone has valid optimization concerns. No need to provide types or hashing functions on every line when the thing’s supposed to know them already.

I wasn’t very happy using Text keys in BTree, but it seems it may be the most optimal solution. Optionally we could have a library that compresses case insensitive [a-z0-9] key text into another text (not blob) and this way it will probably take 1/3 of the space. (Example: “PeterLee” becomes “a$C”)

6 Likes