InProgress
open class InProgress : OptionalRustObject
This class wraps a raw pointer that points to a Rust InProgress object.
InProgress allows for multiple transacts to be performed in a single transaction.
Each transact performed results in a TxReport that can be used to gather information
to be used in subsequent transacts.
Committing an InProgress commits all the transacts that have been performed using
that InProgress.
Rolling back and InProgress rolls back all the transacts that have been performed
using that InProgress.
do {
let inProgress = try mentat.beginTransaction()
let txReport = try inProgress.transact(transaction: "[[:db/add "a" :foo/long 22]]")
let aEntid = txReport.entid(forTempId: "a")
let report = try inProgress.transact(transaction: "[[:db/add "b" :foo/ref \(aEntid)] [:db/add "b" :foo/boolean true]]")
try inProgress.commit()
} catch {
...
}
InProgress also provides a number of functions to generating an builder to assert datoms programatically.
The two types of builder are InProgressBuilder and EntityBuilder.
InProgressBuilder takes the current InProgress and provides a programmatic interface to add
and retract values from entities for which there exists an Entid. The provided InProgress
is used to perform the transacts.
let aEntid = txReport.entid(forTempId: "a")
let bEntid = txReport.entid(forTempId: "b")
do {
let inProgress = try mentat.beginTransaction()
let builder = try inProgress.builder()
try builder.add(entid: bEntid, keyword: ":foo/boolean", boolean: true)
try builder.add(entid: aEntid, keyword: ":foo/instant", date: newDate)
let (inProgress, report) = try builder.transact()
try inProgress.transact(transaction: "[[:db/add \(aEntid) :foo/long 22]]")
try inProgress.commit()
} catch {
...
}
EntityBuilder takes the current InProgress and either an Entid or a tempid to provide
a programmatic interface to add and retract values from a specific entity. The provided InProgress
is used to perform the transacts.
do {
let transaction = try mentat.beginTransaction()
let builder = try transaction.builder(forTempId: "b")
try builder.add(keyword: ":foo/boolean", boolean: true)
try builder.add(keyword: ":foo/instant", date: newDate)
let (inProgress, report) = try builder.transact()
let bEntid = report.entid(forTempId: "b")
try inProgress.transact(transaction: "[[:db/add \(bEntid) :foo/long 22]]")
try inProgress.commit()
} catch {
...
}
-
Creates an
InProgressBuilderusing thisInProgress.Throws
PointerError.pointerConsumedif the underlying raw pointer has already consumed, which will occur if theInProgresshas already been committed, or converted into a Builder.Declaration
Swift
open func builder() throws -> InProgressBuilderReturn Value
an
InProgressBuilderfor thisInProgress -
Creates an
EntityBuilderusing thisInProgressfor the entity withentid.Throws
PointerError.pointerConsumedif the underlying raw pointer has already consumed, which will occur if theInProgresshas already been committed, or converted into a Builder.Declaration
Swift
open func builder(forEntid entid: Int64) throws -> EntityBuilderParameters
entidThe
Entidfor this entity.Return Value
an
EntityBuilderfor thisInProgress -
Creates an
EntityBuilderusing thisInProgressfor a new entity withtempId.Throws
PointerError.pointerConsumedif the underlying raw pointer has already consumed, which will occur if theInProgresshas already been committed, or converted into a Builder.Declaration
Swift
open func builder(forTempId tempId: String) throws -> EntityBuilderParameters
tempIdThe temporary identifier for this entity.
Return Value
an
EntityBuilderfor thisInProgress -
Transacts the
transactionThis does not commit the transaction. In order to do so,
commitcan be called.Throws
PointerError.pointerConsumedif the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.errorif the transaction failed.Throws
ResultError.emptyif noTxReportis returned from the transact.Declaration
Swift
open func transact(transaction: String) throws -> TxReportParameters
transactionThe EDN string to be transacted.
Return Value
The
TxReportgenerated by the transact. -
Commits all the transacts that have been performed on this `InProgress`, either directly or through a Builder.Throws
PointerError.pointerConsumedif the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.errorif the commit failed.Declaration
Swift
open func commit() throws -
Rolls back all the transacts that have been performed on this
InProgress, either directly or through a Builder.Throws
PointerError.pointerConsumedif the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.errorif the rollback failed.Declaration
Swift
open func rollback() throws -
Undocumented
Declaration
Swift
override open func cleanup(pointer: OpaquePointer)
InProgress Class Reference