A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.mongodb.com/docs/realm-sdks/swift/latest/Classes/EmbeddedObject.html below:

EmbeddedObject Class Reference

EmbeddedObject

EmbeddedObject is a base class used to define embedded Realm model objects.

Embedded objects work similarly to normal objects, but are owned by a single parent Object (which itself may be embedded). Unlike normal top-level objects, embedded objects cannot be directly created in or added to a Realm. Instead, they can only be created as part of a parent object, or by assigning an unmanaged object to a parent object’s property. Embedded objects are automatically deleted when the parent object is deleted or when the parent is modified to no longer point at the embedded object, either by reassigning an Object property or by removing the embedded object from the List containing it.

Embedded objects can only ever have a single parent object which links to them, and attempting to link to an existing managed embedded object will throw an exception.

The property types supported on EmbeddedObject are the same as for Object, except for that embedded objects cannot link to top-level objects, so Object and List<Object> properties are not supported (EmbeddedObject and List<EmbeddedObject> are).

Embedded objects cannot have primary keys or indexed properties.

class Owner: Object {
    @objc dynamic var name: String = ""
    let dogs = List<Dog>()
}
class Dog: EmbeddedObject {
    @objc dynamic var name: String = ""
    @objc dynamic var adopted: Bool = false
    let owner = LinkingObjects(fromType: Owner.self, property: "dogs")
}

Key-Value Coding & Subscripting


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4