Type Aliases

The following type aliases are available globally.

Aliases

  • PropertyType is an enum describing all property types supported in Realm models.

    For more information, see Object Models and Schemas.

    Primitive types

    • Int
    • Bool
    • Float
    • Double

    Object types

    Relationships: Array (in Swift, List) and Object types

    Declaration

    Swift

    public typealias PropertyType = RLMPropertyType
  • An opaque token which is returned from methods which subscribe to changes to a Realm.

    Declaration

    Swift

    public typealias NotificationToken = RLMNotificationToken
  • An object representing the Realm App configuration

    See

    RLMAppConfiguration

    Note

    AppConfiguration options cannot be modified once the App using it is created. App’s configuration values are cached when the App is created so any modifications after it will not have any effect.

    Declaration

    Swift

    public typealias AppConfiguration = RLMAppConfiguration
  • An object representing a client which performs network calls on Realm Cloud user api keys

    See

    RLMAPIKeyAuth

    Declaration

    Swift

    public typealias APIKeyAuth = RLMAPIKeyAuth
  • An object representing a client which performs network calls on Realm Cloud user registration & password functions

    See

    RLMEmailPasswordAuth

    Declaration

    Swift

    public typealias EmailPasswordAuth = RLMEmailPasswordAuth
  • An object representing the social profile of a User.

    Declaration

    Swift

    public typealias UserProfile = RLMUserProfile
  • A block type used to report an error

    Declaration

    Swift

    public typealias EmailPasswordAuthOptionalErrorBlock = RLMEmailPasswordAuthOptionalErrorBlock
  • An object representing a client which performs network calls on Realm Cloud for registering devices to push notifications

    See

    see RLMPushClient

    Declaration

    Swift

    public typealias PushClient = RLMPushClient
  • An object which is used within UserAPIKeyProviderClient

    Declaration

    Swift

    public typealias UserAPIKey = RLMUserAPIKey
  • App

    The App has the fundamental set of methods for communicating with a Realm application backend. This interface provides access to login and authentication.

    Declaration

    Swift

    public typealias App = RLMApp
  • Use this delegate to be provided a callback once authentication has succeed or failed

    Declaration

    Swift

    @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
    public typealias ASLoginDelegate = RLMASLoginDelegate
  • AsymmetricObject is a base class used to define asymmetric Realm objects.

    Asymmetric objects can only be created using the create(_ type:, value:) function, and cannot be added, removed or queried. When created, asymmetric objects will be synced unidirectionally to the MongoDB database and cannot be accessed locally.

    Linking an asymmetric object within an Object is not allowed and will throw an error.

    The property types supported on AsymmetricObject are the same as for Object, except for that asymmetric objects can only link to embedded objects, so Object and List<Object> properties are not supported (EmbeddedObject and List<EmbeddedObject> are).

    class Person: AsymmetricObject {
        @Persisted(primaryKey: true) var _id: ObjectId
        @Persisted var name: String
        @Persisted var age: Int
    }
    

    Declaration

    Swift

    public typealias AsymmetricObject = RealmSwiftAsymmetricObject
  • A Dictionary object representing a BSON document.

    Declaration

    Swift

    public typealias Document = Dictionary<String, AnyBSON?>
  • MaxKey will always be the greatest value when comparing to other BSON types

    Declaration

    Swift

    public typealias MaxKey = RLMMaxKey
  • MinKey will always be the smallest value when comparing to other BSON types

    Declaration

    Swift

    public typealias MinKey = RLMMinKey
  • Object is a class used to define Realm model objects.

    In Realm you define your model classes by subclassing Object and adding properties to be managed. You then instantiate and use your custom subclasses instead of using the Object class directly.

    class Dog: Object {
        @Persisted var name: String
        @Persisted var adopted: Bool
        @Persisted var siblings: List<Dog>
    }
    

    Supported property types

    • String
    • Int, Int8, Int16, Int32, Int64
    • Float
    • Double
    • Bool
    • Date
    • Data
    • Decimal128
    • ObjectId
    • UUID
    • AnyRealmValue
    • Any RawRepresentable enum whose raw type is a legal property type. Enums must explicitly be marked as conforming to PersistableEnum.
    • Object subclasses, to model many-to-one relationships
    • EmbeddedObject subclasses, to model owning one-to-one relationships

    All of the types above may also be Optional, with the exception of AnyRealmValue. Object and EmbeddedObject subclasses must be Optional.

    In addition to individual values, three different collection types are supported:

    • List<Element>: an ordered mutable collection similar to Array.
    • MutableSet<Element>: an unordered uniquing collection similar to Set.
    • Map<String, Element>: an unordered key-value collection similar to Dictionary.

    The Element type of collections may be any of the supported non-collection property types listed above. Collections themselves may not be Optional, but the values inside them may be, except for lists and sets of Object or EmbeddedObject subclasses.

    Finally, LinkingObjects properties can be used to track which objects link to this one.

    All properties which should be stored by Realm must be explicitly marked with @Persisted. Any properties not marked with @Persisted will be ignored entirely by Realm, and may be of any type.

    Querying

    You can retrieve all objects of a given type from a Realm by calling the objects(_:) instance method.

    Relationships

    See our Swift guide for more details.

    Declaration

    Swift

    public typealias Object = RealmSwiftObject
  • 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 {
        @Persisted var name: String
        @Persisted var dogs: List<Dog>
    }
    class Dog: EmbeddedObject {
        @Persisted var name: String
        @Persisted var adopted: Bool
        @Persisted(originProperty: "dogs") var owner: LinkingObjects<Owner>
    }
    

    Declaration

    Swift

    public typealias EmbeddedObject = RealmSwiftEmbeddedObject
  • A struct that represents the coordinates of a point formed by a latitude and a longitude value.

    • Latitude ranges between -90 and 90 degrees, inclusive.
    • Longitude ranges between -180 and 180 degrees, inclusive.

    Values outside this ranges will return nil when trying to create a GeoPoint.

    Note

    There is no dedicated type to store Geospatial points, instead points should be stored as GeoJson-shaped embedded object, as explained below. Geospatial queries (geoWithin) can only be executed in such a type of objects and will throw otherwise.

    Persisting geo points in Realm is currently done using duck-typing, which means that any model class with a specific shape can be queried as though it contained a geographical location.

    the following is required:

    • A String property with the value of Point: @Persisted var type: String = "Point".
    • A List containing a Longitude/Latitude pair: @Persisted private var coordinates: List<Double>.

    The recommended approach is using an embedded object.

    public class Location: EmbeddedObject {
      @Persisted private var coordinates: List<Double>
      @Persisted private var type: String = "Point"
    
      public var latitude: Double { return coordinates[1] }
      public var longitude: Double { return coordinates[0] }
    
      convenience init(_ latitude: Double, _ longitude: Double) {
          self.init()
          // Longitude comes first in the coordinates array of a GeoJson document
          coordinates.append(objectsIn: [longitude, latitude])
        }
      }
    

    Warning

    This structure cannot be persisted and can only be used to build other geospatial shapes such as (GeoBox, GeoPolygon and GeoCircle).

    Declaration

    Swift

    public typealias GeoPoint = RLMGeospatialPoint
  • A class that represents a rectangle, that can be used in a geospatial geoWithinquery.

    Warning

    This class cannot be persisted and can only be use within a geospatial geoWithin query.

    Declaration

    Swift

    public typealias GeoBox = RLMGeospatialBox
  • A class that represents a polygon, that can be used in a geospatial geoWithinquery.

    A GeoPolygon describes a shape conformed of and outer Polygon, called outerRing, and 0 or more inner Polygons, called holes, which represents an unlimited number of internal holes inside the outer Polygon. A Polygon describes a shape conformed by at least three segments, where the last and the first GeoPoint must be the same to indicate a closed polygon (meaning you need at least 4 points to define a polygon). Inner holes in a GeoPolygon must be entirely inside the outer ring

    A hole has the following restrictions:

    • Holes may not cross, i.e. the boundary of a hole may not intersect both the interior and the exterior of any other hole.
    • Holes may not share edges, i.e. if a hole contains and edge AB, the no other hole may contain it.
    • Holes may share vertices, however no vertex may appear twice in a single hole.
    • No hole may be empty.
    • Only one nesting is allowed.

    Warning

    This class cannot be persisted and can only be use within a geospatial geoWithin query.

    Warning

    Altitude is not used in any of the query calculations.

    Declaration

    Swift

    public typealias GeoPolygon = RLMGeospatialPolygon
  • This structure is a helper to represent/convert a distance. It can be used in geospatial queries like those represented by a GeoCircle

    Warning

    This structure cannot be persisted and can only be used to build other geospatial shapes

    Declaration

    Swift

    public typealias Distance = RLMDistance
  • A class that represents a circle, that can be used in a geospatial geoWithinquery.

    Warning

    This class cannot be persisted and can only be use within a geospatial geoWithin query.

    Declaration

    Swift

    public typealias GeoCircle = RLMGeospatialCircle
  • The type of a migration block used to migrate a Realm.

    Declaration

    Swift

    public typealias MigrationBlock = @Sendable (_ migration: Migration, _ oldSchemaVersion: UInt64) -> Void

    Parameters

    migration

    A Migration object used to perform the migration. The migration object allows you to enumerate and alter any existing objects which require migration.

    oldSchemaVersion

    The schema version of the Realm being migrated.

  • An object class used during migrations.

    Declaration

    Swift

    public typealias MigrationObject = DynamicObject
  • A block type which provides both the old and new versions of an object in the Realm. Object properties can only be accessed using subscripting.

    Declaration

    Swift

    public typealias MigrationObjectEnumerateBlock = (_ oldObject: MigrationObject?, _ newObject: MigrationObject?) -> Void

    Parameters

    oldObject

    The object from the original Realm (read-only).

    newObject

    The object from the migrated Realm (read-write).

  • Migration instances encapsulate information intended to facilitate a schema migration.

    A Migration instance is passed into a user-defined MigrationBlock block when updating the version of a Realm. This instance provides access to the old and new database schemas, the objects in the Realm, and provides functionality for modifying the Realm during the migration.

    Declaration

    Swift

    public typealias Migration = RLMMigration
  • The MongoClient enables reading and writing on a MongoDB database via the Realm Cloud service.

    It provides access to instances of MongoDatabase, which in turn provide access to specific MongoCollections that hold your data.

    Note

    Before you can read or write data, a user must log in.

    Declaration

    Swift

    public typealias MongoClient = RLMMongoClient
  • The MongoDatabase represents a MongoDB database, which holds a group of collections that contain your data.

    It can be retrieved from the MongoClient.

    Use it to get MongoCollections for reading and writing data.

    Note

    Before you can read or write data, a user must log in`.

    Declaration

    Swift

    public typealias MongoDatabase = RLMMongoDatabase
  • Options to use when executing a find command on a MongoCollection.

    Declaration

    Swift

    public typealias FindOptions = RLMFindOptions
  • Options to use when executing a findOneAndUpdate, findOneAndReplace, or findOneAndDelete command on a MongoCollection.

    Declaration

    Swift

    public typealias FindOneAndModifyOptions = RLMFindOneAndModifyOptions
  • The result of an updateOne or updateMany operation a MongoCollection.

    Declaration

    Swift

    public typealias UpdateResult = RLMUpdateResult
  • Block which returns Result.success(DocumentId) on a successful insert or Result.failure(error)

    Declaration

    Swift

    public typealias MongoInsertBlock = @Sendable (Result<AnyBSON, Error>) -> Void
  • Block which returns Result.success([ObjectId]) on a successful insertMany or Result.failure(error)

    Declaration

    Swift

    public typealias MongoInsertManyBlock = @Sendable (Result<[AnyBSON], Error>) -> Void
  • Block which returns Result.success([Document]) on a successful find operation or Result.failure(error)

    Declaration

    Swift

    public typealias MongoFindBlock = @Sendable (Result<[Document], Error>) -> Void
  • Block which returns Result.success(Document?) on a successful findOne operation or Result.failure(error)

    Declaration

    Swift

    public typealias MongoFindOneBlock = @Sendable (Result<Document?, Error>) -> Void
  • Block which returns Result.success(Int) on a successful count operation or Result.failure(error)

    Declaration

    Swift

    public typealias MongoCountBlock = @Sendable (Result<Int, Error>) -> Void
  • Block which returns Result.success(UpdateResult) on a successful update operation or Result.failure(error)

    Declaration

    Swift

    public typealias MongoUpdateBlock = @Sendable (Result<UpdateResult, Error>) -> Void
  • The MongoCollection represents a MongoDB collection.

    You can get an instance from a MongoDatabase.

    Create, read, update, and delete methods are available.

    Operations against the Realm Cloud server are performed asynchronously.

    Note

    Before you can read or write data, a user must log in.

    Declaration

    Swift

    public typealias MongoCollection = RLMMongoCollection
  • Acts as a middleman and processes events with WatchStream

    Declaration

    Swift

    public typealias ChangeStream = RLMChangeStream
  • The Id of the asynchronous transaction.

    Declaration

    Swift

    public typealias AsyncTransactionId = RLMAsyncTransactionId

Notifications

  • The type of a block to run for notification purposes when the data in a Realm is modified.

    Declaration

    Swift

    public typealias NotificationBlock = (_ notification: Realm.Notification, _ realm: Realm) -> Void
  • Logger is used for creating your own custom logging logic.

    You can define your own logger creating an instance of Logger and define the log function which will be invoked whenever there is a log message.

    let logger = Logger(level: .all) { level, message in
       print("Realm Log - \(level): \(message)")
    }
    

    Set this custom logger as you default logger using Logger.shared.

       Logger.shared = inMemoryLogger
    

    Note

    By default default log threshold level is .info, and logging strings are output to Apple System Logger.

    Declaration

    Swift

    public typealias Logger = RLMLogger
  • An object representing an Atlas App Services user.

    See

    RLMUser

    Declaration

    Swift

    public typealias User = RLMUser
  • A manager which configures and manages Atlas App Services synchronization-related functionality.

    See

    RLMSyncManager

    Declaration

    Swift

    public typealias SyncManager = RLMSyncManager
  • Options for configuring timeouts and intervals in the sync client.

    See

    RLMSyncTimeoutOptions

    Declaration

    Swift

    public typealias SyncTimeoutOptions = RLMSyncTimeoutOptions
  • A session object which represents communication between the client and server for a specific Realm.

    See

    RLMSyncSession

    Declaration

    Swift

    public typealias SyncSession = RLMSyncSession
  • A closure type for a closure which can be set on the SyncManager to allow errors to be reported to the application.

    See

    RLMSyncErrorReportingBlock

    Declaration

    Swift

    public typealias ErrorReportingBlock = RLMSyncErrorReportingBlock
  • A closure type for a closure which is used by certain APIs to asynchronously return a SyncUser object to the application.

    See

    RLMUserCompletionBlock

    Declaration

    Swift

    public typealias UserCompletionBlock = RLMUserCompletionBlock
  • An error associated with the SDK’s synchronization functionality. All errors reported by an error handler registered on the SyncManager are of this type.

    See

    RLMSyncError

    Declaration

    Swift

    public typealias SyncError = RLMSyncError
  • Extended information about a write which was rejected by the server.

    The server will sometimes reject writes made by the client for reasons such as permissions, additional server-side validation failing, or because the object didn’t match any flexible sync subscriptions. When this happens, a .writeRejected error is reported with a non-nil SyncError.compensatingWriteInfo field with information about what writes were rejected and why.

    This information is intended for debugging and logging purposes only. The reason strings are generated by the server and are not guaranteed to be stable, so attempting to programmatically do anything with them will break without warning.

    Declaration

    Swift

    public typealias CompensatingWriteInfo = RLMCompensatingWriteInfo
  • An error which occurred when making a request to Atlas App Services. Most User and App functions which can fail report errors of this type.

    Declaration

    Swift

    public typealias AppError = RLMAppError
  • An enum which can be used to specify the level of logging.

    See

    RLMSyncLogLevel

    Declaration

    Swift

    public typealias SyncLogLevel = RLMSyncLogLevel
  • A data type whose values represent different authentication providers that can be used with Atlas App Services.

    See

    RLMIdentityProvider

    Declaration

    Swift

    public typealias Provider = RLMIdentityProvider
  • A configuration controlling how the initial subscriptions are populated when a Realm file is first opened.

    See

    RLMInitialSubscriptionsConfiguration

    Declaration

    Swift

    public typealias InitialSubscriptionsConfiguration = RLMInitialSubscriptionsConfiguration