EntityBuilder
public class EntityBuilder<T>
Class used together with ModelBuilder by the code generator to specify the fields and their indexes in an entity. Typical usage is:
let eBuilder = mBuilder.entityBuilder(for: MyEntity.self, id: 1, uid: 1001)
eBuilder.addProperty(name: "id", type: .long, flags: [.id, .unsigned], id: 1, uid: 1001)
eBuilder.addProperty(name: "userName", type: .string, id: 2, uid: 1002)
eBuilder.lastProperty(id: 2, uid: 1002)
and so on. Note that there may be only one EntityBuilder
in existence at any one time.
It is currently not supported to use a previous EntityBuilder
after creating a new one using ModelBuilder
‘s
entityBuilder()
method.
See ModelBuilder
for more.
You usually don’t have to deal with this class.
-
Undocumented
Declaration
Swift
public func flags(_ flags: EntityFlags) throws
-
Undocumented
Declaration
Swift
public func flags(_ flags: [EntityFlags]) throws
-
Add the given property to this entity. An overload to accept a single flag.
Declaration
Swift
@discardableResult public func addProperty(name: String, type: PropertyType, flags: PropertyFlags, id: UInt32, uid: UInt64, indexId: UInt32 = 0, indexUid: UInt64 = 0) throws -> PropertyBuilder
-
Add the given property to this entity.
Declaration
Swift
@discardableResult public func addProperty(name: String, type: PropertyType, flags: [PropertyFlags] = [], id: UInt32, uid: UInt64, indexId: UInt32 = 0, indexUid: UInt64 = 0) throws -> PropertyBuilder
-
Add a to-one-relation (e.g. a pointer from a parent to its children) to the model.
Declaration
Swift
public func addToOneRelation(name: String, targetEntityInfo: EntityInfo, flags: [PropertyFlags] = [], id propertyID: UInt32, uid propertyUID: UInt64, indexId indexID: UInt32, indexUid indexUID: UInt64) throws
-
Add a standalone to-many-relation from this entity to another to the model.
Declaration
Swift
public func addToManyRelation(id relationId: obx_schema_id, uid relationUid: obx_uid, targetId: obx_schema_id, targetUid: obx_uid) throws
-
Register the highest property ID used for this entity.
Declaration
Swift
public func lastProperty(id propertyID: UInt32, uid propertyUID: UInt64) throws