API
OrionORM.Model — TypeModel(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.
Base.filter — Methodfilter(model::DataType; kwargs...)Filters records of model by the keyword arguments provided and returns the matching instances.
OrionORM._build_where — Method_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.
OrionORM.buildBatchInsertQuery — MethodbuildBatchInsertQuery(model::DataType, records::Vector{Dict{String,Any}})Generates a single INSERT statement with placeholders for multiple records, returning (sql, params) suitable for prepared execution.
OrionORM.buildDeleteQuery — MethodbuildDeleteQuery(model::DataType, where::Dict)Gera: sql = "DELETE FROM table WHERE (…)"; params = [where-params…]
OrionORM.buildInsertQuery — MethodbuildInsertQuery(model::DataType, data::Dict{String,Any})Gera: sql = "INSERT INTO table (col1,col2,…) VALUES (?,?,…)" params = [val1, val2, …]
OrionORM.buildSelectQuery — MethodbuildSqlQuery(model::DataType, query::Dict)Devolve (sql,params) prontos para DBInterface.prepare/execute.
OrionORM.buildUpdateQuery — MethodbuildUpdateQuery(model::DataType, data::Dict, where::Dict)Gera: sql = "UPDATE table SET col1 = ?, col2 = ? WHERE (…)" params = [val1, val2, …, [where-params…]]
OrionORM.create — Methodcreate(model::DataType, data::Dict{String,Any})Inserts a new record for model, auto-generating UUIDs when needed, and returns the created instance.
OrionORM.createMany — MethodcreateMany(model::DataType, data::Vector{<:Dict};
chunkSize::Int=1000, transaction::Bool=true)Inserts multiple records in batches. Returns true on success.
OrionORM.delete — Methoddelete(modelInstance)Deletes the record corresponding to modelInstance in the database using its primary key, and returns true on success.
OrionORM.delete — Methoddelete(model::DataType, query::AbstractDict)Deletes records in model matching query["where"] and returns true on success.
OrionORM.deleteMany — FunctiondeleteMany(model::DataType, query::AbstractDict=Dict())Deletes all records in model matching query["where"] and returns true on success.
OrionORM.executeQuery — FunctionexecuteQuery(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). Whenfalse, the statement is executed without starting a transaction—useful if you are already insideDBInterface.transaction.
Returns
- A
DataFrameif 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
DataFrameif the result is tabular. - Otherwise, the raw result (e.g. number of affected rows).
OrionORM.findUnique — MethodfindUnique(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.
OrionORM.update — Methodupdate(modelInstance)Updates the record corresponding to modelInstance in the database using its primary key, and returns the updated instance.
OrionORM.update — Methodupdate(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.
OrionORM.updateMany — MethodupdateMany(model::DataType, query, data::Dict{String,Any})Updates all records matching query["where"] with the given data and returns the updated instances.
OrionORM.updateManyAndReturn — MethodupdateManyAndReturn(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.
OrionORM.upsert — Methodupsert(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.