Introduction

Ballerina ORM is a Prisma-inspired ORM for Ballerina. It uses annotated Ballerina record types as the schema source of truth and provides a fluent query builder for MySQL and PostgreSQL.

Who this is for

This documentation is for developers who want to:

  • Ballerina developers should not need a second schema DSL.
  • Record types and annotations are already expressive enough.
  • Query authoring should feel concise, fluent, and predictable.
  • preserve escape hatches for raw SQL when needed
  • use one API across MySQL and PostgreSQL

Core ideas

IdeaWhat it means
Your types are your schemaAnnotated Ballerina records define table metadata, fields, relations, and indexes.
Fluent query builderQuery chains are readable and composable (where, orderBy, take, include, etc.).
Dialect abstractionIdentifier quoting and placeholders are handled per database dialect.
Official driver integrationorm:Client wraps ballerinax/mysql and ballerinax/postgresql.

Documentation map

First query preview

ballerina
import thambaru/bal_orm.orm;

var users = check db.'from(User)
    .'where({email: {contains: "@example.com"}})
    .orderBy({createdAt: orm:DESC})
    .take(10)
    .findMany();

Next step

Continue with Installation to set up dependencies and database connectivity.