Skip to content
Snippets Groups Projects
Commit 3daa6ee5 authored by florian's avatar florian
Browse files

ENH: Implement create_transaction

parent 82d75b25
No related branches found
No related tags found
1 merge request!7ENH: Implement queries and entity retrieval
......@@ -23,6 +23,8 @@
module Transaction
export create_transaction
using CaosDB
"""
......@@ -50,4 +52,38 @@ mutable struct _Transaction
end
end
"""
create_transaction(name::AbstractString = "default")
Return a transaction created with the connection of the given name. If
none is given, the defult connection is used.
"""
function create_transaction(name::AbstractString = "default")
connection = CaosDB.Connection.get_connection(name)
return create_transaction(connection)
end
"""
function create_transaction(connection::Ref{CaosDB.Connection._Connection})
Return a transactioncreated with the given connection object.
"""
function create_transaction(connection::Ref{CaosDB.Connection._Connection})
transaction = Ref{_Transaction}(_Transaction(true))
err_code = ccall(
(:caosdb_connection_connection_create_transaction, CaosDB.library_name),
Cint,
(Ref{CaosDB.Connection._Connection}, Ref{_Transaction}),
connection,
transaction,
)
CaosDB.Exceptions.evaluate_return_code(err_code)
return transaction
end
end # Transaction
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment