Core
-
The Store represents an ObjectBox database on the local disk. For each persisted object type, you can obtain a
Boxinstance with thebox(for:)method. Boxes provide the interfaces for object persistence.A typical setup sequence looks like this:
let store = try Store(directoryPath: pathToStoreData) let personBox = store.box(for: Person.self) let persons = try personBox.all()See moreNote
You must run the code generator by building at least once to create a Store initializer according to your data model. This generated initializer does not have a “model” parameter (that one is an internal initializer), and comes with convenient defaults for its named parameters.Declaration
Swift
public class Store : CustomDebugStringConvertible -
Declaration
Swift
public class Box<E: EntityInspectable & __EntityRelatable>: CustomDebugStringConvertible where E == E.EntityBindingType.EntityType -
Base protocol of anything you want to persist in a box.
Persisted Properties
All stored properties of a type that conforms to
Entitywill be persisted, if possible. For numbers, ObjectBox recognizesBool,Int8,Int16,Int32,Int64,Int(plus their unsigned variants),Float, andDouble. It also recognizesString,DateandData(the latter of which may also be written as[UInt8]).Relations
To create relations between entities, use
ToOneandToManyto wrap the target type, likecustomer: ToOne<Customer>.Informal requirements: It is assumed that classes implementing this have an init() method and all properties to be serialized are mutable. For struct types, it is assumed that an init method exists that accepts all properties to be serialized.
Declaration
Swift
public protocol Entity -
ID for objects (entities) stored in ObjectBox. Each entity class/struct must have an ID.
Declaration
Swift
public typealias Id = UInt64 -
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.
See moreDeclaration
Swift
public struct Property<E: EntityInspectable & __EntityRelatable, V: EntityPropertyTypeConvertible, R> where E == E.EntityBindingType.EntityType
View on GitHub
Install in Dash
Core Reference