Crate hoardbase[][src]

Expand description

Usage

Hoardbase tries to provide a similar programming interface as that of mongodb. If you are already familiar with mongodb, using Hoardbase should be very simple.

Internals

The key mechanism for storing and querying json data using sqlite is serializing json documents into the blob type. Currently bson is used as the serialized format. Another interesting format is Amazon Ion. I may add support for Ion in the future when its rust binding matures.

Indexing and searching is implemented using sqlite’s application-defined functions. Basically, we can define custom functions that operates on the blob type to extract a json field, or patch a blob. As long as those custom functions are deterministic, they can be used for indexing and searching. For example, we can define a function bson_field(path, blob) that extracts a bson field from the blob. If we invoke this function with WHERE bson_field('name.id', blob) = 3 against a collection, we will find all documents with name.id equals to 3. We can also create indices on bson fields using this function. For more references, these are some good links:

how to query json within a database

sqlite json support

Modules

Macros

This macro is for convenience. The purpose of this macro is to construct a callback function to process find results. Because the callback’s signature is very complex, we recommend using this macro.