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
keywordto be the providedvalue.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 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) throwsParameters
keywordThe name of the attribute in the format
:namespace/name.valueThe value to be asserted
-
Asserts the value of attribute
keywordto be the providedvalue.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 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) throwsParameters
keywordThe name of the attribute in the format
:namespace/name.valueThe value to be asserted
-
Asserts the value of attribute
keywordto be the providedvalue.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 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) throwsParameters
keywordThe name of the attribute in the format
:namespace/name.valueThe value to be asserted
-
Asserts the value of attribute
keywordto be the providedvalue.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 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) throwsParameters
keywordThe name of the attribute in the format
:namespace/name.valueThe value to be asserted
-
Asserts the value of attribute
keywordto be the providedvalue.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 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) throwsParameters
keywordThe name of the attribute in the format
:namespace/name.valueThe value to be asserted
-
Asserts the value of attribute
keywordto be the providedvalue.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 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) throwsParameters
keywordThe name of the attribute in the format
:namespace/name.valueThe value to be asserted
-
Asserts the value of attribute
keywordto be the providedvalue.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 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) throwsParameters
keywordThe name of the attribute in the format
:namespace/name.valueThe value to be asserted
-
Asserts the value of attribute
keywordto be the providedvalue.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 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) throwsParameters
keywordThe name of the attribute in the format
:namespace/name.valueThe value to be asserted
-
Retracts the value of attribute
keywordfrom the providedvalue.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 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) throwsParameters
keywordThe name of the attribute in the format
:namespace/name.valueThe value to be retracted
-
Retracts the value of attribute
keywordfrom the providedvalue.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 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) throwsParameters
keywordThe name of the attribute in the format
:namespace/name.valueThe value to be retracted
-
Retracts the value of attribute
keywordfrom the providedvalue.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 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) throwsParameters
keywordThe name of the attribute in the format
:namespace/name.valueThe value to be retracted
-
Retracts the value of attribute
keywordfrom the providedvalue.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 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) throwsParameters
keywordThe name of the attribute in the format
:namespace/name.valueThe value to be retracted
-
Retracts the value of attribute
keywordfrom the providedvalue.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 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) throwsParameters
keywordThe name of the attribute in the format
:namespace/name.valueThe value to be retracted
-
Retracts the value of attribute
keywordfrom the providedvalue.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 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) throwsParameters
keywordThe name of the attribute in the format
:namespace/name.valueThe value to be retracted
-
Retracts the value of attribute
keywordfrom the providedvalue.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 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) throwsParameters
keywordThe name of the attribute in the format
:namespace/name.valueThe value to be retracted
-
Retracts the value of attribute
keywordfrom the providedvalue.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 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) throwsParameters
keywordThe name of the attribute in the format
:namespace/name.valueThe value to be retracted
-
Transacts the added assertions. This consumes the pointer associated with this
EntityBuildersuch that no further assertions can be added after thetransacthas completed. To perform further assertions, use theInProgressreturned from this function.This does not commit the transaction. In order to do so,
commitcan be called on theInProgressreturned from this function.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 an error occured during the execution of the transact.Declaration
Swift
open func transact() throws -> (InProgress, TxReport?)Return Value
The current
InProgressand theTxReportgenerated by the transact. -
Transacts the added assertions and commits. This consumes the pointer associated with this
EntityBuilderand the associatedInProgresssuch that no further assertions can be added after thecommithas completed. To perform further assertions, a newInProgressorEntityBuildershould be created.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 an error occured during the execution of the transact.Declaration
Swift
open func commit() throws -> TxReportReturn Value
The
TxReportgenerated by the transact. -
Undocumented
Declaration
Swift
override open func cleanup(pointer: OpaquePointer)
EntityBuilder Class Reference