Annotations Reference

Entity-level annotations

AnnotationPayloadDescription
@orm:EntityEntityConfigMaps record to table, schema, and engine
@orm:IndexIndexConfig (repeatable)Adds single/composite index metadata

EntityConfig

FieldTypeDefault
tableNamestring?inferred from model name
schemastring?none
engineorm:Engine?inherited from client context

IndexConfig

FieldTypeDefault
namestring?auto-generated
columnsstring[]required
uniquebooleanfalse

Field-level annotations

AnnotationPayloadDescription
@orm:IdMarkerPrimary key marker
@orm:AutoIncrementMarkerAuto-increment marker
@orm:ColumnColumnConfigColumn mapping options
@orm:RelationRelationConfigRelation metadata
@orm:CreatedAtMarkerCreation timestamp marker
@orm:UpdatedAtMarkerUpdate timestamp marker
@orm:IgnoreMarkerExclude field from persistence

ColumnConfig

FieldTypeDefault
namestring?field name
'typestring?inferred from field type
lengthint?none
nullablebooleantrue
uniquebooleanfalse
'defaultanydata?none

RelationConfig

FieldTypeDefault
'typeorm:RelationType?required in practice
modelstring?inferred
referencesstring[]?none
foreignKeystring[]?none
joinTablestring?none

Example

ballerina
@orm:Entity {tableName: "users"}
@orm:Index {columns: ["email"], unique: true}
public type User record {|
    @orm:Id @orm:AutoIncrement
    int id;

    @orm:Column {nullable: false, length: 255}
    string email;

    @orm:Relation {'type: orm:ONE_TO_MANY}
    Post[]? posts;
|};