bal_orm.orm
Modules
bal_orm.orm
Module bal_orm.orm
API
Declarations
Definitions
thambaru/bal_orm.orm
Functions
'from
function 'from(typedesc<anydata> modelType) returns QueryBuilderStart a query builder from a model type descriptor.
Parameters
- modelType typedesc<anydata> - Type descriptor of the model record type.
Return Type
- QueryBuilder - A new QueryBuilder scoped to the inferred model name.
analyzeSchemaForPlugin
function analyzeSchemaForPlugin(SchemaGraph graph) returns PluginDiagnostic[]Compile-time validation helpers for ORM schema plugin diagnostics. Analyze schema relationships and return plugin diagnostics.
Parameters
- graph SchemaGraph - The parsed schema graph to analyze.
Return Type
- PluginDiagnostic[] - List of diagnostics produced by relation validation.
areRelationTypesCompatible
Shared type mapping helpers for compiler-plugin analysis and generation.
Returns true if two Ballerina field types are compatible for relation keys.
Parameters
- sourceType string - Ballerina type string of the foreign key field.
- targetType string - Ballerina type string of the referenced primary key field.
Return Type
- boolean -
trueif the two types are considered compatible for relation mapping.
createInputFieldType
Returns a type string suitable for generated create inputs.
Parameters
- ballerinaType string - The original Ballerina type string.
Return Type
- string - The base type without optional or array decorators.
emitFieldIdentifier
Emit a Ballerina field identifier, quoting keyword-like names when needed.
Parameters
- fieldName string - The field name to emit.
Return Type
- string - The field name prefixed with
'if it is a Ballerina keyword.
executeCompilerPlugin
function executeCompilerPlugin(RawSchema rawSchema) returns PluginExecution|SchemaErrorConvenience API that runs the default plugin implementation.
Parameters
- rawSchema RawSchema - Raw schema input derived from annotated record types.
Return Type
- PluginExecution|SchemaError - A PluginExecution with the schema graph, generated artifacts, and diagnostics.
fromModel
function fromModel(string modelName) returns QueryBuilderStart a query builder from a model name.
Parameters
- modelName string - Explicit model name string.
Return Type
- QueryBuilder - A new QueryBuilder scoped to the given model name.
generateModelArtifacts
function generateModelArtifacts(SchemaGraph graph) returns map<ModelGeneration>Type and CRUD wrapper generation for ORM models. Generate model-level type and CRUD sources for all schema models.
Parameters
- graph SchemaGraph - The parsed schema graph containing all model definitions.
Return Type
- map<ModelGeneration> - Map of model name to generated type and CRUD source payloads.
hasPluginErrors
function hasPluginErrors(PluginExecution execution) returns booleanReturns true if the plugin reported at least one error diagnostic.
Parameters
- execution PluginExecution - Plugin execution output to inspect.
Return Type
- boolean -
trueif at least one ERROR-severity diagnostic is present.
includedRelations
function includedRelations(IncludeInput input) returns string[]Collect relation names that are explicitly included with true.
Parameters
- input IncludeInput - Relation include map.
Return Type
- string[] - List of relation field names whose value is
true.
isLogicalWhereOperator
Checks whether the provided key is a logical where operator.
Parameters
- key string - Field key from the where input map.
Return Type
- boolean -
trueif the key isAND,OR, orNOT.
mysqlPlaceholder
Placeholder for MySQL positional parameters.
Parameters
- index int - 1-based parameter index (ignored for MySQL).
Return Type
- string - The literal
?placeholder string.
mysqlQuoteIdentifier
MySQL dialect helpers. Quote an identifier using MySQL rules.
Parameters
- identifier string - Raw identifier string to quote.
Return Type
- string - Backtick-quoted identifier safe for use in MySQL SQL strings.
normalizeClientConfig
function normalizeClientConfig(ClientConfig config) returns NormalizedClientConfig|ClientErrorNormalize client config from explicit fields and/or connection URL.
Parameters
- config ClientConfig - Raw client configuration potentially containing a connection URL.
Return Type
- NormalizedClientConfig|ClientError - Fully resolved and validated configuration, or a ClientError.
parseConnectionUrl
function parseConnectionUrl(string connectionUrl) returns ParsedConnectionUrl|ClientErrorParse database connection URLs into normalized provider/host/credential values.
Parameters
- connectionUrl string - Connection URL string (e.g.
mysql://user:pass@host:3306/db).
Return Type
- ParsedConnectionUrl|ClientError - Parsed connection values, or a ClientError if the URL is invalid.
parseModel
function parseModel(RawModel rawModel, Engine? defaultEngine) returns ModelDefinition|SchemaErrorParse a single raw model into a model definition.
Parameters
- rawModel RawModel - Normalized source definition for the model.
- defaultEngine Engine? (default ()) - Fallback database engine if the model does not specify one.
Return Type
- ModelDefinition|SchemaError - Parsed model definition, or a SchemaError.
parseSchema
function parseSchema(RawSchema rawSchema) returns SchemaGraph|SchemaErrorParse normalized schema source values into ORM schema IR. Parse a full schema graph and validate cross-model constraints.
Parameters
- rawSchema RawSchema - Normalized schema source to parse.
Return Type
- SchemaGraph|SchemaError - Fully parsed and validated schema graph, or a SchemaError.
postgresqlPlaceholder
Placeholder for PostgreSQL positional parameters.
Parameters
- index int - 1-based parameter index.
Return Type
- string - A
$nplaceholder string (e.g.$1,$2).
postgresqlQuoteIdentifier
PostgreSQL dialect helpers. Quote an identifier using PostgreSQL rules.
Parameters
- identifier string - Raw identifier string to quote.
Return Type
- string - Double-quoted identifier safe for use in PostgreSQL SQL strings.
rawExecute
Build ad-hoc parameterized SQL execute payload.
Parameters
- text string - Raw SQL statement string with placeholders.
- params anydata... - Positional parameter values.
Return Type
- SqlQuery - A SqlQuery payload ready for execution.
rawQuery
Build ad-hoc parameterized SQL query payload.
Parameters
- text string - Raw SQL query string with placeholders.
- params anydata... - Positional parameter values.
Return Type
- SqlQuery - A SqlQuery payload ready for execution.
resolveConnectionPool
function resolveConnectionPool(ConnectionPoolConfig? poolConfig) returns ConnectionPoolConfig?Resolve ORM pool config into the shared SQL connection pool type.
Parameters
- poolConfig ConnectionPoolConfig? (default ()) - Optional pool configuration to resolve.
Return Type
- ConnectionPoolConfig? - The resolved pool config, or nil if none was provided.
selectedFields
function selectedFields(SelectInput input) returns string[]Extract top-level selected fields where the value is true.
Parameters
- input SelectInput - Select projection map.
Return Type
- string[] - List of field names whose value is
true.
toParameterizedSqlQuery
function toParameterizedSqlQuery(SqlQuery sqlQuery, Engine provider) returns ParameterizedQuery|ClientErrorConvert generated SQL payload to a sql:ParameterizedQuery.
Parameters
- sqlQuery SqlQuery - SQL text and positional parameters to convert.
- provider Engine - Database provider that determines placeholder syntax.
Return Type
- ParameterizedQuery|ClientError - A sql:ParameterizedQuery ready for execution, or a ClientError.
toSql
function toSql(QueryPlan plan, Engine engine) returns SqlQuery|SchemaErrorConvert a query plan into dialect-aware SQL and parameter bindings. Convert a query plan to SQL for the selected engine.
Parameters
- plan QueryPlan - Compiled query plan to convert.
- engine Engine (default MYSQL) - Target database engine that determines SQL dialect.
Return Type
- SqlQuery|SchemaError - SQL text with positional parameters, or a SchemaError.
updateInputFieldType
Returns a type string suitable for generated update inputs.
Parameters
- ballerinaType string - The original Ballerina type string.
- nullable boolean - Whether the field should be treated as optional in update inputs.
Return Type
- string - The base type, optionally suffixed with
?for nullable update fields.
validateSchemaGraph
function validateSchemaGraph(SchemaGraph graph) returns SchemaError?Validation functions for schema graph consistency checks. Validate model-level and cross-model constraints.
Parameters
- graph SchemaGraph - The parsed schema graph to validate.
Return Type
- SchemaError? - A SchemaError if a constraint violation is found, otherwise nil.
Classes
bal_orm.orm: Client
ORM database client wrapper for MySQL and PostgreSQL backends.
getConfig
function getConfig() returns NormalizedClientConfigReturns the normalized configuration used by this client.
Return Type
- NormalizedClientConfig - Normalized configuration with the password redacted.
getNativeClient
function getNativeClient() returns NativeDbClientExpose the underlying database client for low-level SQL operations.
Return Type
- NativeDbClient - The underlying mysql:Client or postgresql:Client handle.
query
function query(QueryPlan plan) returns stream<record {}, Error?>|SchemaError|ClientError|ErrorConvert a query plan to SQL and execute it as a read query.
Use this for findMany, findFirst, findUnique, count, and aggregate operations.
Parameters
- plan QueryPlan - Compiled query plan describing the read operation.
Return Type
- stream<record {}, Error?>|SchemaError|ClientError|Error - A stream of generic record rows, or an error.
execute
function execute(QueryPlan plan) returns ExecutionResult|SchemaError|ClientError|ErrorConvert a query plan to SQL and execute it as a write query.
Use this for create, createMany, update, updateMany, upsert, delete, and deleteMany operations.
Parameters
- plan QueryPlan - Compiled query plan describing the write operation.
Return Type
- ExecutionResult|SchemaError|ClientError|Error - SQL execution result, or an error.
rawQuery
function rawQuery(string text, anydata[] params) returns stream<record {}, Error?>|ClientError|ErrorExecute raw SQL query text with positional parameters. Returns a generic record stream. Cast result rows to your model type using a type descriptor.
Parameters
- text string - Raw SQL query string with
?(MySQL) or$n(PostgreSQL) placeholders.
- params anydata[] (default []) - Positional parameter values matching the placeholders.
Return Type
- stream<record {}, Error?>|ClientError|Error - A stream of generic record rows, or an error.
rawExecute
function rawExecute(string text, anydata[] params) returns int|ClientError|ErrorExecute raw SQL statement text with positional parameters. Returns the number of affected rows.
Parameters
- text string - Raw SQL statement string with
?(MySQL) or$n(PostgreSQL) placeholders.
- params anydata[] (default []) - Positional parameter values matching the placeholders.
Return Type
- int|ClientError|Error - Number of affected rows, or an error.
model
function model(typedesc<anydata> modelType) returns ExecutingQueryBuilderCreate an executing query builder bound to this client for the given model type.
Terminal methods on the returned builder execute immediately — no separate run step required.
Parameters
- modelType typedesc<anydata> - Type descriptor of the model record type.
Return Type
- ExecutingQueryBuilder - An ExecutingQueryBuilder scoped to the given model.
'from
function 'from(typedesc<anydata> modelType) returns ExecutingQueryBuilderPrimary Prisma-like fluent API entry point. Returns a typed executing query builder.
Example:
User[] users = check db.'from(User) .'where({status: {equals: "ACTIVE"}}) .orderBy({id: orm:DESC}) .findMany();
Parameters
- modelType typedesc<anydata> - Type descriptor of the model record type.
Return Type
- ExecutingQueryBuilder - An ExecutingQueryBuilder scoped to the given model.
close
function close() returns error?Close the underlying database client.
Return Type
- error? - An error if closing fails, otherwise nil.
Fields
- provider Engine - Active database provider for this client instance.
bal_orm.orm: CompilerPlugin
Orchestrates schema scan, analysis, and code generation.
scan
Scan schema payload that was derived from @orm:Entity records.
Parameters
- rawSchema RawSchema - The raw schema to scan.
Return Type
- RawSchema - The scanned (possibly mutated) raw schema.
run
function run(RawSchema rawSchema) returns PluginExecution|SchemaErrorExecute plugin pipeline and return generated outputs and diagnostics.
Parameters
- rawSchema RawSchema - Raw schema input derived from annotated record types.
Return Type
- PluginExecution|SchemaError - A PluginExecution with the schema graph, generated artifacts, and diagnostics.
bal_orm.orm: ExecutingQueryBuilder
Fluent query builder that is pre-bound to a live ORM client. Terminal methods execute immediately — no separate query-runner step required.
Obtain one via db.'from(ModelType) — the primary Prisma-like API entry point.
Example:
User[] users = check db.'from(User) .'where({email: {contains: "@example.com"}}) .orderBy({id: orm:DESC}) .take(10) .findMany();
'table
function 'table(string tableName) returns ExecutingQueryBuilderOverride table name for this query.
Parameters
- tableName string - Custom table name to use instead of the model-derived default.
Return Type
- ExecutingQueryBuilder - Updated builder with the custom table name applied.
'where
function 'where(WhereInput whereInput) returns ExecutingQueryBuilderAdd a where filter.
Parameters
- whereInput WhereInput - Filter predicate map.
Return Type
- ExecutingQueryBuilder - Updated builder with the where clause applied.
orderBy
function orderBy(OrderByInput orderByInput) returns ExecutingQueryBuilderAdd an order-by clause.
Parameters
- orderByInput OrderByInput - Field-to-direction map specifying sort order.
Return Type
- ExecutingQueryBuilder - Updated builder with the order-by clause appended.
skip
function skip(int value) returns ExecutingQueryBuilderSet result offset.
Parameters
- value int - Number of rows to skip.
Return Type
- ExecutingQueryBuilder - Updated builder with the skip value set.
take
function take(int value) returns ExecutingQueryBuilderSet result size limit.
Parameters
- value int - Maximum number of rows to return.
Return Type
- ExecutingQueryBuilder - Updated builder with the take value set.
'select
function 'select(SelectInput selectInput) returns ExecutingQueryBuilderAdd select projection.
Parameters
- selectInput SelectInput - Field projection map.
Return Type
- ExecutingQueryBuilder - Updated builder with the select projection applied.
include
function include(IncludeInput includeInput) returns ExecutingQueryBuilderAdd relation include payload.
Parameters
- includeInput IncludeInput - Relation include map.
Return Type
- ExecutingQueryBuilder - Updated builder with the include clause applied.
findMany
function findMany() returns record {}[]|errorExecute the query and return all matching rows as a generic record array. Cast the result to your model type using a type descriptor.
Return Type
- record {}[]|error - Array of generic record rows, or an error.
findFirst
function findFirst() returns record {}?|errorExecute the query and return the first matching row, or nil if none found. Cast the result to your model type using a type descriptor.
Return Type
- record {}?|error - The first matching generic record, nil if no match, or an error.
findUnique
function findUnique() returns record {}?|errorExecute the query and return the unique matching row, or nil if none found. Cast the result to your model type using a type descriptor.
Return Type
- record {}?|error - The unique matching generic record, nil if no match, or an error.
count
Execute a count query and return the row count.
create
Execute a create query and return the created row as a generic record.
Inserts the row then fetches the full record using the auto-generated primary key.
Assumes the primary key column is named id.
Cast the result to your model type using a type descriptor.
Parameters
- data map<anydata> - Field values to insert.
Return Type
- record {}|error - The newly inserted generic record, or an error.
createMany
Execute a createMany query and return all created rows as a generic record array.
Inserts each row individually and fetches results via auto-generated primary keys.
Assumes the primary key column is named id.
Parameters
- dataList map<anydata>[] - List of field value maps to insert.
Return Type
- record {}[]|error - Array of newly inserted generic records, or an error.
update
Execute an update query and return the updated row as a generic record.
Updates the matching row (limited to one) then fetches back the updated record.
Parameters
- data map<anydata> - Field values to update.
Return Type
- record {}|error - The updated generic record, or an error.
updateMany
Execute an updateMany query and return the number of affected rows.
Parameters
- data map<anydata> - Field values to apply to all matching rows.
upsert
function upsert(map<anydata> createData, map<anydata> updateData) returns ExecutionResult|SchemaError|ClientError|ErrorExecute an upsert query (insert if not exists, otherwise update).
Parameters
- createData map<anydata> - Field values for the insert branch.
- updateData map<anydata> - Field values for the update branch.
Return Type
- ExecutionResult|SchemaError|ClientError|Error - SQL execution result, or an error.
delete
function delete() returns record {}|errorExecute a delete query, returning the deleted row as a generic record.
Fetches the matching record before deletion, deletes it, then returns the fetched record.
Return Type
- record {}|error - The deleted generic record, or an error.
deleteMany
Execute a deleteMany query and return the number of affected rows.
bal_orm.orm: QueryBuilder
Mutable fluent query builder.
'table
function 'table(string tableName) returns QueryBuilderOverride table name for this query.
Parameters
- tableName string - Custom table name to use instead of the model-derived default.
Return Type
- QueryBuilder - Updated builder with the custom table name applied.
'where
function 'where(WhereInput whereInput) returns QueryBuilderAdd a where filter.
Parameters
- whereInput WhereInput - Filter predicate map.
Return Type
- QueryBuilder - Updated builder with the where clause applied.
orderBy
function orderBy(OrderByInput orderByInput) returns QueryBuilderAdd an order-by clause.
Parameters
- orderByInput OrderByInput - Field-to-direction map specifying sort order.
Return Type
- QueryBuilder - Updated builder with the order-by clause appended.
skip
function skip(int value) returns QueryBuilderSet result offset.
Parameters
- value int - Number of rows to skip.
Return Type
- QueryBuilder - Updated builder with the skip value set.
take
function take(int value) returns QueryBuilderSet result size limit.
Parameters
- value int - Maximum number of rows to return.
Return Type
- QueryBuilder - Updated builder with the take value set.
'select
function 'select(SelectInput selectInput) returns QueryBuilderAdd select projection.
Parameters
- selectInput SelectInput - Field projection map.
Return Type
- QueryBuilder - Updated builder with the select projection applied.
include
function include(IncludeInput includeInput) returns QueryBuilderAdd relation include payload.
Parameters
- includeInput IncludeInput - Relation include map.
Return Type
- QueryBuilder - Updated builder with the include clause applied.
findMany
function findMany() returns QueryPlanBuild a find-many query plan.
Return Type
- QueryPlan - Compiled QueryPlan for a FIND_MANY operation.
findUnique
function findUnique() returns QueryPlanBuild a find-unique query plan.
Return Type
- QueryPlan - Compiled QueryPlan for a FIND_UNIQUE operation.
findFirst
function findFirst() returns QueryPlanBuild a find-first query plan.
Return Type
- QueryPlan - Compiled QueryPlan for a FIND_FIRST operation.
create
Build a create query plan.
Parameters
- data map<anydata> - Field values to insert.
Return Type
- QueryPlan - Compiled QueryPlan for a CREATE operation.
createMany
Build a create-many query plan.
Parameters
- dataList map<anydata>[] - List of field value maps to insert.
Return Type
- QueryPlan - Compiled QueryPlan for a CREATE_MANY operation.
update
Build an update query plan.
Parameters
- data map<anydata> - Field values to update.
Return Type
- QueryPlan - Compiled QueryPlan for an UPDATE operation.
updateMany
Build an update-many query plan.
Parameters
- data map<anydata> - Field values to apply to all matching rows.
Return Type
- QueryPlan - Compiled QueryPlan for an UPDATE_MANY operation.
upsert
Build an upsert query plan.
Parameters
- createData map<anydata> - Field values used for the insert branch.
- updateData map<anydata> - Field values used for the update branch.
Return Type
- QueryPlan - Compiled QueryPlan for an UPSERT operation.
delete
function delete() returns QueryPlanBuild a delete query plan.
Return Type
- QueryPlan - Compiled QueryPlan for a DELETE operation.
deleteMany
function deleteMany() returns QueryPlanBuild a delete-many query plan.
Return Type
- QueryPlan - Compiled QueryPlan for a DELETE_MANY operation.
count
function count() returns QueryPlanBuild a count query plan.
Return Type
- QueryPlan - Compiled QueryPlan for a COUNT operation.
aggregate
function aggregate(AggregateInput input) returns QueryPlanBuild an aggregate query plan.
Parameters
- input AggregateInput - Aggregation descriptor map.
Return Type
- QueryPlan - Compiled QueryPlan for an AGGREGATE operation.
Constants
bal_orm.orm: AGGREGATE
bal_orm.orm: ASC
Filter and ordering input types used by the query builder. Sort direction constants.
bal_orm.orm: COUNT
bal_orm.orm: CREATE
bal_orm.orm: CREATE_MANY
bal_orm.orm: DEFAULT_MYSQL_PORT
Default port used by MySQL.
bal_orm.orm: DEFAULT_POSTGRESQL_PORT
Default port used by PostgreSQL.
bal_orm.orm: DELETE
bal_orm.orm: DELETE_MANY
bal_orm.orm: DESC
bal_orm.orm: FIND_FIRST
bal_orm.orm: FIND_MANY
Fluent query builder API for model-scoped operations. Query operation names.
bal_orm.orm: FIND_UNIQUE
bal_orm.orm: MANY_TO_MANY
bal_orm.orm: MANY_TO_ONE
bal_orm.orm: MYSQL
Annotation and metadata types used by the ORM schema system. Supported database providers.
bal_orm.orm: ONE_TO_MANY
bal_orm.orm: ONE_TO_ONE
Supported relation kinds.
bal_orm.orm: PLUGIN_ERROR
Compiler plugin scaffolding for schema analysis and model-aware code generation. Plugin diagnostic severity values.
bal_orm.orm: PLUGIN_WARNING
bal_orm.orm: POSTGRESQL
bal_orm.orm: UPDATE
bal_orm.orm: UPDATE_MANY
bal_orm.orm: UPSERT
Annotations
bal_orm.orm: AutoIncrement
Mark a field as auto-incrementing.
bal_orm.orm: Column
Override column-level properties for a field.
bal_orm.orm: CreatedAt
Mark a field as ORM-managed creation timestamp.
bal_orm.orm: Entity
Attach table-level metadata to a model record type.
bal_orm.orm: Id
Mark a field as part of the primary key.
bal_orm.orm: Ignore
Exclude a field from persistence mapping.
bal_orm.orm: Index
Attach index metadata to a model record type.
Declared as an array so @Index { ... } can be repeated multiple times.
bal_orm.orm: Relation
Attach relation metadata to a relation field.
bal_orm.orm: UpdatedAt
Mark a field as ORM-managed update timestamp.
Records
bal_orm.orm: ClientConfig
Client configuration accepted by orm:Client.
Fields
- provider Engine?(default ()) - Explicit database provider. Inferred from
urlif omitted.
- url string?(default ()) - Full connection URL. Overrides individual fields when supplied.
- host string?(default ()) - Database host name or IP address.
- port int?(default ()) - Database port number.
- user string?(default ()) - Database user name.
- password string?(default ()) - Database password.
- database string?(default ()) - Target database or schema name.
- mysqlOptions Options?(default ()) - Additional MySQL-specific connection options.
- postgresqlOptions Options?(default ()) - Additional PostgreSQL-specific connection options.
- connectionPool ConnectionPoolConfig?(default ()) - Optional connection pool settings.
bal_orm.orm: ClientErrorDetail
Client configuration and URL parser error payload.
Fields
- code string - Machine-readable error code.
- message string - Human-readable error description.
- fieldName string?(default ()) - Name of the configuration field that caused the error, if applicable.
bal_orm.orm: ColumnConfig
Column-level mapping settings.
Fields
- name? string - Column name override. Defaults to the snake_case of the field name.
- 'type? string -
- length? int - Maximum character length for string columns.
- nullable boolean(default true) - Whether the column accepts NULL values.
- unique boolean(default false) - Whether a unique constraint is applied to this column.
- 'default? anydata? -
bal_orm.orm: ColumnDefinition
Parsed column definition.
Fields
- fieldName string - Ballerina field name.
- columnName string - Database column name.
- ballerinaType string - Ballerina type string.
- dbType string? - Explicit database column type override, if any.
- length int? - Maximum character length, if configured.
- nullable boolean - Whether the column accepts NULL values.
- unique boolean - Whether the column has a unique constraint.
- isId boolean - Whether this column is part of the primary key.
- autoIncrement boolean - Whether the column is auto-incremented by the database.
- createdAt boolean - Whether the column is ORM-managed as a creation timestamp.
- updatedAt boolean - Whether the column is ORM-managed as an update timestamp.
- hasDefault boolean - Whether the column has a configured default value.
- defaultValue anydata? - The default value, if any.
bal_orm.orm: EntityConfig
Entity-level mapping settings.
Fields
- tableName? string - Database table name. Defaults to the snake_case plural of the model name.
- schema? string - Optional database schema name prefix.
- engine? Engine - Force a specific database provider for this model.
bal_orm.orm: GeneratedCrudSource
Generated source payload for a CRUD wrapper.
Fields
- name string - Name of the generated CRUD function.
- content string - Ballerina source code for the generated CRUD function.
bal_orm.orm: GeneratedTypeSource
Generated source payload for a type definition.
Fields
- name string - Name of the generated type.
- content string - Ballerina source code for the generated type.
bal_orm.orm: IndexConfig
Index settings for single or composite indexes.
Fields
- name? string - Optional explicit index name. Auto-generated from columns if omitted.
- columns string[] - Field names that form the index.
- unique boolean(default false) - Whether the index enforces uniqueness.
bal_orm.orm: IndexDefinition
Parsed index definition.
Fields
- name string - Index name.
- columns string[] - List of column names forming the index.
- unique boolean - Whether the index enforces uniqueness.
bal_orm.orm: Marker
Marker used for field-level no-payload annotations.
bal_orm.orm: ModelDefinition
Parsed model definition.
Fields
- name string - Model name.
- tableName string - Resolved database table name.
- schema string? - Database schema prefix, if any.
- engine Engine?(default ()) - Database provider override for this model.
- columns ColumnDefinition[] - List of parsed column definitions.
- columnsByField map<ColumnDefinition> - Map from field name to column definition for fast lookup.
- indexes IndexDefinition[] - List of parsed index definitions.
- relations RelationDefinition[] - List of parsed relation definitions.
bal_orm.orm: ModelGeneration
Generated artifacts for a single ORM model.
Fields
- model string - Model name these artifacts were generated for.
- generatedTypes GeneratedTypeSource[] - List of generated type source payloads.
- generatedCrud GeneratedCrudSource[] - List of generated CRUD source payloads.
bal_orm.orm: NormalizedClientConfig
Normalized runtime configuration used by the ORM client.
Fields
- provider Engine - Resolved database provider.
- host string - Resolved host name or IP address.
- port int - Resolved port number.
- user string?(default ()) - Resolved user name, or nil if not set.
- password string?(default ()) - Resolved password, or nil if not set.
- database string?(default ()) - Resolved database name, or nil if not set.
- mysqlOptions Options?(default ()) - MySQL-specific connection options, if applicable.
- postgresqlOptions Options?(default ()) - PostgreSQL-specific connection options, if applicable.
- connectionPool ConnectionPoolConfig?(default ()) - Resolved connection pool settings, if any.
bal_orm.orm: ParsedConnectionUrl
Parsed values from a connection URL.
Fields
- provider Engine - Database provider inferred from the URL scheme.
- host string - Host name or IP address extracted from the URL.
- port int - Port number extracted from the URL.
- user string?(default ()) - User name extracted from the URL authority, if present.
- password string?(default ()) - Password extracted from the URL authority, if present.
- database string?(default ()) - Database name extracted from the URL path, if present.
bal_orm.orm: PluginDiagnostic
Compiler-plugin diagnostic payload.
Fields
- code string - Machine-readable diagnostic code.
- message string - Human-readable diagnostic description.
- severity PluginSeverity - Diagnostic severity: ERROR or WARNING.
- model string?(default ()) - Model name context, if applicable.
- fieldName string?(default ()) - Field name context, if applicable.
bal_orm.orm: PluginExecution
Output returned by the compiler-plugin execution pipeline.
Fields
- schemaGraph SchemaGraph - Parsed schema graph produced from the raw schema.
- modelArtifacts map<ModelGeneration> - Map of model name to generated artifacts.
- diagnostics PluginDiagnostic[](default []) - List of diagnostics emitted during analysis.
bal_orm.orm: QueryPlan
Captured query plan produced by the builder.
Fields
- model string - Model name the query targets.
- tableName string?(default ()) - Optional explicit table name override.
- operation QueryOperation(default FIND_MANY) - Query operation to perform.
- 'where WhereInput?(default ()) -
- orderBy OrderByInput[](default []) - Ordered list of order-by clauses.
- skip int?(default ()) - Number of rows to skip (OFFSET).
- take int?(default ()) - Maximum number of rows to return (LIMIT).
- 'select SelectInput?(default ()) -
- include IncludeInput?(default ()) - Relation include payload.
- data map<anydata>?(default ()) - Write payload for create, update, or upsert operations.
- dataList map<anydata>[]?(default ()) - List of write payloads for createMany.
- upsert UpsertInput?(default ()) - Separate create/update payloads for upsert.
- aggregate AggregateInput?(default ()) - Aggregation input.
bal_orm.orm: RawField
Normalized source definition for a single model field.
Fields
- name string - Field name as declared in the Ballerina record.
- ballerinaType string - Ballerina type string of the field.
- isOptional boolean(default false) - Whether the field is declared as optional.
- isArray boolean(default false) - Whether the field is declared as an array.
- id boolean(default false) - Whether the field is annotated with @orm:Id.
- autoIncrement boolean(default false) - Whether the field is annotated with @orm:AutoIncrement.
- createdAt boolean(default false) - Whether the field is annotated with @orm:CreatedAt.
- updatedAt boolean(default false) - Whether the field is annotated with @orm:UpdatedAt.
- ignored boolean(default false) - Whether the field is annotated with @orm:Ignore.
- column ColumnConfig?(default ()) - Column-level config from @orm:Column, if present.
- relation RelationConfig?(default ()) - Relation config from @orm:Relation, if present.
bal_orm.orm: RawModel
Normalized source definition for a single model.
Fields
- name string - Model name (typically the Ballerina record type name).
- entity EntityConfig(default {}) - Entity-level mapping settings from the @orm:Entity annotation.
- fields RawField[] - List of raw field definitions.
- indexes IndexConfig[](default []) - List of index definitions from @orm:Index annotations.
bal_orm.orm: RawSchema
Input payload consumed by the runtime schema parser.
This is the normalized schema source currently produced manually or by compiler tooling.
Fields
- models RawModel[] - List of raw model definitions.
- defaultEngine Engine?(default ()) - Default database provider applied to all models unless overridden.
bal_orm.orm: RelationConfig
Relation mapping settings.
Fields
- 'type? RelationType -
- model? string - Target model name. Inferred from the Ballerina field type when omitted.
- references? string[] - Primary-key field names on the target model side.
- foreignKey? string[] - Foreign-key field names on the owning model side.
- joinTable? string - Join table name for MANY_TO_MANY relations.
bal_orm.orm: RelationDefinition
Parsed relation definition from one model field.
Fields
- fieldName string - Name of the relation field on this model.
- targetModel string - Name of the related model.
- relationType RelationType - Kind of relation (ONE_TO_ONE, ONE_TO_MANY, etc.).
- references string[] - Primary-key fields on the target model.
- foreignKey string[] - Foreign-key fields on the owning model.
- joinTable string? - Join table name for MANY_TO_MANY relations, if any.
bal_orm.orm: RelationEdge
Directed edge representation for relation graph traversal.
Fields
- fromModel string - Name of the source model.
- fromField string - Name of the relation field on the source model.
- toModel string - Name of the target model.
- relationType RelationType - Kind of relation.
- references string[] - Primary-key fields on the target model.
- foreignKey string[] - Foreign-key fields on the source model.
- joinTable string? - Join table name for MANY_TO_MANY relations, if any.
bal_orm.orm: SchemaGraph
Parsed graph of all models and relation edges.
Fields
- models map<ModelDefinition> - Map of model name to parsed model definition.
- relationEdges RelationEdge[] - Directed relation edges between models.
bal_orm.orm: SchemaIssue
Schema IR and normalized source types used by parser and validator. Error detail payload for schema parsing and validation failures.
Fields
- code string - Machine-readable error code.
- message string - Human-readable description of the failure.
- model string? - Name of the model where the error occurred, if applicable.
- fieldName string? - Name of the field where the error occurred, if applicable.
bal_orm.orm: SqlQuery
SQL payload produced by SQL generation.
Fields
- text string - SQL string with dialect-specific placeholders.
- parameters anydata[](default []) - Ordered list of parameter values matching the placeholders.
bal_orm.orm: UpsertInput
Upsert payload.
Fields
- create map<anydata> - Data for the insert branch.
- update map<anydata> - Data for the update branch.
Errors
bal_orm.orm: ClientError
Client subsystem error type.
bal_orm.orm: SchemaError
Error type used by the schema subsystem.
Union types
bal_orm.orm: QueryOperation
QueryOperation
Supported query operation type.
bal_orm.orm: Engine
Engine
Database provider identifier.
bal_orm.orm: RelationType
RelationType
Relation type identifier.
bal_orm.orm: NativeDbClient
NativeDbClient
Union type used to store either provider client.
bal_orm.orm: PluginSeverity
PluginSeverity
Severity type for plugin diagnostics.
Simple name reference types
bal_orm.orm: ConnectionPoolConfig
ConnectionPoolConfig
Shared connection pool configuration delegated to ballerina/sql.
Map types
bal_orm.orm: SelectInput
SelectInput
Projection input types and helpers. Dynamic select payload.
Top-level keys are field names and values are booleans or nested select maps.
bal_orm.orm: WhereInput
WhereInput
Dynamic where-clause payload.
Field names map to literal values or operator maps.
Logical operators are represented by AND, OR, and NOT keys.
bal_orm.orm: OrderByInput
OrderByInput
Dynamic order-by payload where keys are field names and values are sort directions.
bal_orm.orm: AggregateInput
AggregateInput
Aggregate input payload.
bal_orm.orm: IncludeInput
IncludeInput
Relation include input types and helpers. Dynamic include payload.
Top-level keys are relation field names and values are booleans or nested include/select maps.
Import
import thambaru/bal_orm.orm;Other versions
1.0.0
Metadata
Released date: about 5 hours ago
Version: 1.0.0
Compatibility
Platform: any
Ballerina version: 2201.13.1
GraalVM compatible: Yes
Pull count
Total: 0
Current verison: 0
Weekly downloads