API

OrionORM.ModelType
Model(modelName::Symbol,
            columnsDef::Vector{<:Tuple{String,String,Vector{<:Any}}};
            relationshipsDef::Vector{<:Tuple{Symbol,Symbol,Symbol,Symbol}} = [])

Define um modelo em runtime, criando o struct, registrando-o no modelRegistry, executando a migração e cadastrando relacionamentos.

source
Base.filterMethod
filter(model::DataType; kwargs...)

Filters records of model by the keyword arguments provided and returns the matching instances.

source
OrionORM._build_whereMethod
_build_where(where)::NamedTuple{(:clause,:params)}

Recebe qualquer Dict compatível com a sintaxe Prisma e devolve clause::String (com placeholders ?) e params::Vector na ordem certa.

source
OrionORM.buildBatchInsertQueryMethod
buildBatchInsertQuery(model::DataType, records::Vector{Dict{String,Any}})

Generates a single INSERT statement with placeholders for multiple records, returning (sql, params) suitable for prepared execution.

source
OrionORM.buildDeleteQueryMethod
buildDeleteQuery(model::DataType, where::Dict)

Gera: sql = "DELETE FROM table WHERE (…)"; params = [where-params…]

source
OrionORM.buildInsertQueryMethod
buildInsertQuery(model::DataType, data::Dict{String,Any})

Gera: sql = "INSERT INTO table (col1,col2,…) VALUES (?,?,…)" params = [val1, val2, …]

source
OrionORM.buildUpdateQueryMethod
buildUpdateQuery(model::DataType, data::Dict, where::Dict)

Gera: sql = "UPDATE table SET col1 = ?, col2 = ? WHERE (…)" params = [val1, val2, …, [where-params…]]

source
OrionORM.createMethod
create(model::DataType, data::Dict{String,Any})

Inserts a new record for model, auto-generating UUIDs when needed, and returns the created instance.

source
OrionORM.createManyMethod
createMany(model::DataType, data::Vector{<:Dict};
           chunkSize::Int=1000, transaction::Bool=true)

Inserts multiple records in batches. Returns true on success.

source
OrionORM.deleteMethod
delete(modelInstance)

Deletes the record corresponding to modelInstance in the database using its primary key, and returns true on success.

source
OrionORM.deleteMethod
delete(model::DataType, query::AbstractDict)

Deletes records in model matching query["where"] and returns true on success.

source
OrionORM.deleteManyFunction
deleteMany(model::DataType, query::AbstractDict=Dict())

Deletes all records in model matching query["where"] and returns true on success.

source
OrionORM.executeQueryFunction
executeQuery(conn::DBInterface.Connection, stmt::String, params::Vector{Any}=Any[]; useTransaction::Bool=true)

Prepare and execute a SQL statement on the given connection, returning the result as a DataFrame for queries that return rows, or the raw result (e.g., number of affected rows) otherwise.

Arguments

  • conn::DBInterface.Connection: The database connection to use.
  • stmt::String: The SQL query string to prepare.
  • params::Vector{Any}: A vector of parameters to bind to the prepared statement (default: Any[]).
  • useTransaction::Bool: Whether to run the statement inside a new transaction (default: true). When false, the statement is executed without starting a transaction—useful if you are already inside DBInterface.transaction.

Returns

  • A DataFrame if the underlying result is tabular.
  • Otherwise, returns the raw result from DBInterface.execute, such as the number of affected rows.

Throws

  • Rethrows any exception raised during statement preparation or execution.

Returns

  • A DataFrame if the result is tabular.
  • Otherwise, the raw result (e.g. number of affected rows).
source
OrionORM.findUniqueMethod
findUnique(model::DataType, uniqueField, value; query=Dict())

Finds a single record by a unique field. Returns an instance of the model if found, or nothing if no matching record exists.

source
OrionORM.updateMethod
update(modelInstance)

Updates the record corresponding to modelInstance in the database using its primary key, and returns the updated instance.

source
OrionORM.updateMethod
update(model::DataType, query::AbstractDict, data::Dict{String,Any})

Updates records in model matching query["where"] with the fields in data, and returns the first updated instance.

source
OrionORM.updateManyMethod
updateMany(model::DataType, query, data::Dict{String,Any})

Updates all records matching query["where"] with the given data and returns the updated instances.

source
OrionORM.updateManyAndReturnMethod
updateManyAndReturn(model::DataType, query::AbstractDict, data::Dict{String,Any})

Updates all records in model matching query["where"] with the values in data and returns the updated instances.

source
OrionORM.upsertMethod
upsert(model::DataType, uniqueField, value, data::Dict{String,Any})

Creates a new record if none exists with the given unique field, otherwise updates the existing record.

source