ByteORM is a lightweight ORM for Rust that generates a fully typed client crate from a Prisma-like
.boschema. Define your schema, runbyteorm push, and use a typed Rust client with query builders, CRUD operations, and connection pooling.
byteorm initThis creates byteorm.toml, a starter schema.bo, and a generated-client ignore entry. Existing projects that already use byteorm/*.bo or generated/ keep that layout.
Example byteorm.toml for a single schema:
[schema]
path = "schema.bo"
[client]
output = ".byteorm/client"
crate_name = "byteorm-client"
dependency_source = "vendored"Example for multi-schema projects:
[schema]
directory = "byteorm"
[client]
output = "generated"
crate_name = "byteorm-client"
dependency_source = "vendored"ByteORM v0.1.x keeps dependency_source = "vendored" as the default. The generated client includes its matching byteorm-macros copy, so projects do not need separate crates.io packages yet.
Create or edit schema.bo:
enum PostStatus {
Draft
Published
Archived
}
model User {
id BigInt PrimaryKey
email String Unique
username String NotNull
created_at TimestamptZ @default(now())
}
model Post {
id BigInt PrimaryKey
user_id BigInt NotNull ForeignKey(User.id, onDelete: cascade)
title String NotNull
content String NotNull
status PostStatus @default(Draft)
created_at TimestamptZ @default(now()) Index
updated_at TimestamptZ @default(now())
}
Generate the typed client without touching the database:
byteorm generatePush schema changes to the database and regenerate the client:
byteorm pushIf a migration would drop tables, columns, or enum types, ByteORM stops unless you explicitly accept it:
byteorm push --accept-data-lossInspect resolved paths and config:
byteorm doctorGenerate shell autocomplete scripts:
byteorm completions
byteorm completions install
byteorm completions powershell
byteorm completions zsh
byteorm completions bashbyteorm completions detects the current shell and prints the recommended install command. byteorm completions install writes the completion script to the standard location for bash, zsh, fish, PowerShell, or elvish.
For a one-off bash session without installing anything:
source <(byteorm completions bash)The install scripts also detect the current shell and ask whether to install autocomplete automatically. Set BYTEORM_INSTALL_COMPLETIONS=1 to install without prompting, or BYTEORM_INSTALL_COMPLETIONS=0 to skip it.
Add the generated client path printed by byteorm init or byteorm push to your Cargo.toml:
[dependencies]
byteorm-client = { path = ".byteorm/client" }Then use it from Rust:
use byteorm_client::{Client, PostStatus};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let client = Client::new("postgres://user:pass@localhost:5432/mydb").await?;
let user = client.user.create(|u| {
u.set_email("[email protected]")
.set_username("alice")
}).await?;
let post = client.post.create(|p| {
p.set_user_id(user.id)
.set_title("Hello ByteORM")
.set_content("This is my first post using ByteORM!")
.set_status(PostStatus::Draft)
}).await?;
println!("Created post: {} (id={})", post.title, post.id);
Ok(())
}A complete working example lives in
examples/blog/. Run it withcargo run --example blogfrom that directory.
The IntelliJ MVP lives in integrations/intellij/byteorm-intellij/.
It is intentionally kept as a normal subproject rather than a git submodule so the editor-support code stays close to ByteORM while remaining easy to extract later into a dedicated repo for IntelliJ, VS Code, Zed, or other editors.
