rust-store-core
One data engine for MongoDB, MySQL, PostgreSQL and SQLite. A MongoDB-style query language (GQL), permission checks, computed columns, command planning and SQL dialect translation — as a plain Rust library that opens no connection, starts no clock and generates no randomness.
rust-store-core is the engine behind rust-store-node (napi-rs) and rust-store-py (PyO3), and through them behind nodejs-store and py-store.
Install
What it does
| Step | Function | Input → output |
|---|---|---|
| Parse + plan | command::plan_query |
GQL + params + registry + context → QueryPlan (MongoDB command JSON) |
| Translate | dialect::translate |
command JSON + Backend → parameterized SQL statements |
| Rehydrate | dialect::restore_rows_json |
flat JOIN rows → nested documents |
The host is the only IO boundary: it takes the planned command, runs it against its own driver, and hands the rows back for rehydration.
Three guarantees
- No IO, no clock, no randomness.
nowandnew_idsare always passed in by the caller. This is what makes the engine deterministic and reproducible across languages. - Explicit over silent. Anything that cannot be translated safely returns an error or an
unsupportedmarker plus warnings. The engine never emits SQL that is quietly missing a clause. - JSON in, JSON out. The Node.js and Python bindings only convert and forward, so the two hosts cannot drift apart semantically.
Quickstart
use ;
use plan_query;
use ;
use Registry;
let mut registry = new;
registry.register?;
let gql = "Post($condition:@c0,$sort:@s1,$limit:@l0){title, status, views}";
let mut params = new;
params.insert;
params.insert;
params.insert;
let plan = plan_query?;
for cmd in &plan.commands
A runnable version lives in examples/quickstart.rs — cargo run --example quickstart.
GQL in one look
ModelName($condition:@c0,$sort:@s1,$skip:@sk,$limit:@l1) {
field1, field2, obj.subField,
RelationName($condition:@c2,$sort:@s3,$limit:@l2) { field3, NestedRelation { field4 } }
}
Values are referenced from the params object by @key. Relations are declared in the schema and compiled by the engine into $lookup / $addFields — you never hand-write $lookup. Root-level $group / $having are supported, with the same operator whitelist ($count / $sum / $avg / $min / $max) on both the Mongo and the SQL side.
Documentation
- Full documentation site — https://coenddt.github.io/rust-store/ — scenario walkthroughs with runnable code and the engine's exact limits, one indexable page per scenario.
- API reference — https://docs.rs/rust-store-core
- Repository — https://github.com/coenddt/rust-store
License
MIT