EntityBuilder
open class EntityBuilder : OptionalRustObject
This class wraps a raw pointer that points to a Rust EntityBuilder<InProgressBuilder>
object.
EntityBuilder
provides a programmatic interface to performing assertions on a specific entity.
It provides functions for adding and retracting values for attributes for an entity within
an in progress transaction.
The transact
function will transact the assertions that have been added to the EntityBuilder
and pass back the TxReport
that was generated by this transact and the InProgress
that was
used to perform the transact. This enables you to perform further transacts on the same InProgress
before committing.
let aEntid = txReport.entid(forTempId: "a")
let bEntid = txReport.entid(forTempId: "b")
do {
let builder = try mentat.entityBuilder(forEntid: bEntid)
try builder.add(keyword: ":foo/boolean", boolean: true)
try builder.add(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 {
...
}
The commit
function will transact and commit the assertions that have been added to the EntityBuilder
.
It will consume the InProgress
used to perform the transact. It returns the TxReport
generated by
the transact. After calling commit
, a new transaction must be started by calling Mentat.beginTransaction()
in order to perform further actions.
let aEntid = txReport.entid(forTempId: "a")
do {
let builder = try mentat.entityBuilder(forEntid: aEntid)
try builder.add(keyword: ":foo/boolean", boolean: true)
try builder.add(keyword: ":foo/instant", date: newDate)
let report = try builder.commit()
...
} catch {
...
}
-
Asserts the value of attribute
keyword
to be the providedvalue
.Throws
PointerError.pointerConsumed
if the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.error
if the attribute is not present in the schema or the attribute value type is not:db.type/long
.Declaration
Swift
open func add(keyword: String, long value: Int64) throws
Parameters
keyword
The name of the attribute in the format
:namespace/name
.value
The value to be asserted
-
Asserts the value of attribute
keyword
to be the providedvalue
.Throws
PointerError.pointerConsumed
if the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.error
if the attribute is not present in the schema or the attribute value type is not:db.type/ref
.Declaration
Swift
open func add(keyword: String, reference value: Int64) throws
Parameters
keyword
The name of the attribute in the format
:namespace/name
.value
The value to be asserted
-
Asserts the value of attribute
keyword
to be the providedvalue
.Throws
PointerError.pointerConsumed
if the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.error
if the attribute is not present in the schema or the attribute value type is not:db.type/keyword
.Declaration
Swift
open func add(keyword: String, keyword value: String) throws
Parameters
keyword
The name of the attribute in the format
:namespace/name
.value
The value to be asserted
-
Asserts the value of attribute
keyword
to be the providedvalue
.Throws
PointerError.pointerConsumed
if the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.error
if the attribute is not present in the schema or the attribute value type is not:db.type/boolean
.Declaration
Swift
open func add(keyword: String, boolean value: Bool) throws
Parameters
keyword
The name of the attribute in the format
:namespace/name
.value
The value to be asserted
-
Asserts the value of attribute
keyword
to be the providedvalue
.Throws
PointerError.pointerConsumed
if the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.error
if the attribute is not present in the schema or the attribute value type is not:db.type/double
.Declaration
Swift
open func add(keyword: String, double value: Double) throws
Parameters
keyword
The name of the attribute in the format
:namespace/name
.value
The value to be asserted
-
Asserts the value of attribute
keyword
to be the providedvalue
.Throws
PointerError.pointerConsumed
if the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.error
if the attribute is not present in the schema or the attribute value type is not:db.type/instant
.Declaration
Swift
open func add(keyword: String, date value: Date) throws
Parameters
keyword
The name of the attribute in the format
:namespace/name
.value
The value to be asserted
-
Asserts the value of attribute
keyword
to be the providedvalue
.Throws
PointerError.pointerConsumed
if the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.error
if the attribute is not present in the schema or the attribute value type is not:db.type/string
.Declaration
Swift
open func add(keyword: String, string value: String) throws
Parameters
keyword
The name of the attribute in the format
:namespace/name
.value
The value to be asserted
-
Asserts the value of attribute
keyword
to be the providedvalue
.Throws
PointerError.pointerConsumed
if the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.error
if the attribute is not present in the schema or the attribute value type is not:db.type/uuid
.Declaration
Swift
open func add(keyword: String, uuid value: UUID) throws
Parameters
keyword
The name of the attribute in the format
:namespace/name
.value
The value to be asserted
-
Retracts the value of attribute
keyword
from the providedvalue
.Throws
PointerError.pointerConsumed
if the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.error
if the attribute is not present in the schema or the attribute value type is not:db.type/long
.Declaration
Swift
open func retract(keyword: String, long value: Int64) throws
Parameters
keyword
The name of the attribute in the format
:namespace/name
.value
The value to be retracted
-
Retracts the value of attribute
keyword
from the providedvalue
.Throws
PointerError.pointerConsumed
if the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.error
if the attribute is not present in the schema or the attribute value type is not:db.type/ref
.Declaration
Swift
open func retract(keyword: String, reference value: Int64) throws
Parameters
keyword
The name of the attribute in the format
:namespace/name
.value
The value to be retracted
-
Retracts the value of attribute
keyword
from the providedvalue
.Throws
PointerError.pointerConsumed
if the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.error
if the attribute is not present in the schema or the attribute value type is not:db.type/keyword
.Declaration
Swift
open func retract(keyword: String, keyword value: String) throws
Parameters
keyword
The name of the attribute in the format
:namespace/name
.value
The value to be retracted
-
Retracts the value of attribute
keyword
from the providedvalue
.Throws
PointerError.pointerConsumed
if the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.error
if the attribute is not present in the schema or the attribute value type is not:db.type/boolean
.Declaration
Swift
open func retract(keyword: String, boolean value: Bool) throws
Parameters
keyword
The name of the attribute in the format
:namespace/name
.value
The value to be retracted
-
Retracts the value of attribute
keyword
from the providedvalue
.Throws
PointerError.pointerConsumed
if the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.error
if the attribute is not present in the schema or the attribute value type is not:db.type/double
.Declaration
Swift
open func retract(keyword: String, double value: Double) throws
Parameters
keyword
The name of the attribute in the format
:namespace/name
.value
The value to be retracted
-
Retracts the value of attribute
keyword
from the providedvalue
.Throws
PointerError.pointerConsumed
if the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.error
if the attribute is not present in the schema or the attribute value type is not:db.type/instant
.Declaration
Swift
open func retract(keyword: String, date value: Date) throws
Parameters
keyword
The name of the attribute in the format
:namespace/name
.value
The value to be retracted
-
Retracts the value of attribute
keyword
from the providedvalue
.Throws
PointerError.pointerConsumed
if the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.error
if the attribute is not present in the schema or the attribute value type is not:db.type/string
.Declaration
Swift
open func retract(keyword: String, string value: String) throws
Parameters
keyword
The name of the attribute in the format
:namespace/name
.value
The value to be retracted
-
Retracts the value of attribute
keyword
from the providedvalue
.Throws
PointerError.pointerConsumed
if the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.error
if the attribute is not present in the schema or the attribute value type is not:db.type/uuid
.Declaration
Swift
open func retract(keyword: String, uuid value: UUID) throws
Parameters
keyword
The name of the attribute in the format
:namespace/name
.value
The value to be retracted
-
Transacts the added assertions. This consumes the pointer associated with this
EntityBuilder
such that no further assertions can be added after thetransact
has completed. To perform further assertions, use theInProgress
returned from this function.This does not commit the transaction. In order to do so,
commit
can be called on theInProgress
returned from this function.Throws
PointerError.pointerConsumed
if the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.error
if an error occured during the execution of the transact.Declaration
Swift
open func transact() throws -> (InProgress, TxReport?)
Return Value
The current
InProgress
and theTxReport
generated by the transact. -
Transacts the added assertions and commits. This consumes the pointer associated with this
EntityBuilder
and the associatedInProgress
such that no further assertions can be added after thecommit
has completed. To perform further assertions, a newInProgress
orEntityBuilder
should be created.Throws
PointerError.pointerConsumed
if the underlying raw pointer has already consumed, which will occur if the builder has already been transacted or committed.Throws
ResultError.error
if an error occured during the execution of the transact.Declaration
Swift
open func commit() throws -> TxReport
Return Value
The
TxReport
generated by the transact. -
Undocumented
Declaration
Swift
override open func cleanup(pointer: OpaquePointer)