Instructions¶
These steps install the library, generate Mojo from a JSON Schema, and run the tests. The runtime needs Mojo 1.1.0. Code generation is a Mojo program in this repository. It does not shell out to another BSON library.
Install¶
- Install pixi.
- Clone the repository and install the Mojo 1.1.0 pin.
If pixi install returns 401 or 403 from conda.modular.com, put
PREFIX_API_KEY in a file named .env in this directory and run
scripts/ci-setup.sh. That file is listed in .gitignore. Do not commit it.
The published linux-64 package is on prefix.dev:
The package installs bson.mojoc, wire.mojoc, runtime.mojoc,
schema.mojoc, and the gld-bsongen-mojo command.
Generate¶
A schema file is JSON Schema plus MongoDB bsonType names (int, long,
double) and $ref entries under $defs. scripts/generate.sh reads
testdata/schema/*.json and writes tests/generated/.
Test¶
pixi run test runs every tests/test_*.mojo file. The oracle encodes
documents with pymongo and checks that this library decodes and re-encodes
the same bytes. pymongo is not linked into the Mojo binary.
This site¶
The published copy is leo-gan.github.io/gld-bson.