Property

public struct Property<E: EntityInspectable & __EntityRelatable, V: EntityPropertyTypeConvertible, R>
where E == E.EntityBindingType.EntityType

Metadata of object properties, used by the framework to determine how to store the values.

These are created by the code generator for you.

Usually, you only deal with this class when writing queries. The property names you use in your queries are actually instances of Property, and you can use operators and comparison methods like isLessThan() on them to express your queries. Below you see a list of methods that are available to you for property queries, apart from the operators described under Query Syntax.

  • Entity type that contains the property this object is describing.

    Declaration

    Swift

    public typealias EntityType = E
  • Supported property value type this is describing.

    Declaration

    Swift

    public typealias ValueType = V
  • If this is a ToOne property, this is the type it refers to. Otherwise Void.

    Declaration

    Swift

    public typealias ReferencedType = R
  • Undocumented

    Declaration

    Swift

    public init(propertyId: UInt32, isPrimaryKey: Bool = false)
  • Indicates if the property is the entity’s primary key.

    Declaration

    Swift

    public var isPrimaryKey: Bool { get }
  • The internal ID of the property, in terms of the database schema.

    Declaration

    Swift

    public var propertyId: UInt32 { get }
  • Performs an approximate nearest neighbor (ANN) search to find objects near to the given queryVector.

    This requires the vector property to have an HNSW index.

    The dimensions of the query vector should be at least the dimensions of this vector property.

    Use maxCount to set the maximum number of objects to return by the ANN condition. Hint: it can also be used as the “ef” HNSW parameter to increase the search quality in combination with a query limit. For example, use maxResultCount of 100 with a query limit of 10 to have 10 results that are of potentially better quality than just passing in 10 for maxResultCount (quality/performance tradeoff).

    To change the given parameters after building the query, use Query.setParameter(_:to:) with either a [Float] or [Int] or their alias equivalent.

    Declaration

    Swift

    public func nearestNeighbors(queryVector: [Float], maxCount: Int)
    -> PropertyQueryCondition<EntityType, ValueType>