Realm class Realm

A Realm instance represents a Realm database.

Implemented types

Constructors

Realm(Configuration config)
Opens a Realm using a Configuration object.

Properties

config Configuration
The Configuration object used to open this Realm
final
dynamic DynamicRealm
An object encompassing this Realm instance's dynamic API.
latefinal
hashCode int
The hash code for this object.
no setterinherited
isClosed bool
Checks whether the Realm is closed.
no setter
isFrozen bool
Gets a value indicating whether this Realm is frozen. Frozen Realms are immutable and will not update when writes are made to the database.
latefinal
isInTransaction bool
Checks whether the Realm is in write transaction.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
schema RealmSchema
The schema of this Realm. If the Configuration was created with a non-empty list of schemas, this will match the collection. Otherwise, the schema will be read from the file.
latefinal
subscriptions SubscriptionSet
The active SubscriptionSet for this Realm
no setter
syncSession Session
The Session for this Realm. The sync session is responsible for two-way synchronization with MongoDB Atlas. If the Realm is not synchronized, accessing this property will throw.
no setter

Methods

add<T extends RealmObject>(T object, {bool update = false}) → T
Adds a RealmObject to the Realm.
addAll<T extends RealmObject>(Iterable<T> items, {bool update = false}) → void
Adds a collection RealmObjects to this Realm.
all<T extends RealmObject>() RealmResults<T>
Returns all RealmObjects of type T in the Realm
beginWrite() Transaction
Begins a write transaction for this Realm.
beginWriteAsync([CancellationToken? cancellationToken]) Future<Transaction>
Asynchronously begins a write transaction for this Realm. You can supply a CancellationToken to cancel the operation.
close() → void
Closes the Realm.
delete<T extends RealmObjectBase>(T object) → void
Deletes a RealmObject from this Realm.
deleteAll<T extends RealmObject>() → void
Deletes all RealmObjects of type T in the Realm
deleteMany<T extends RealmObject>(Iterable<T> items) → void
Deletes many RealmObjects from this Realm.
find<T extends RealmObject>(Object? primaryKey) → T?
Fast lookup for a RealmObject with the specified primaryKey.
freeze() Realm
Returns a frozen (immutable) snapshot of this Realm.
ingest<T extends AsymmetricObject>(T object) → void
Ingest an AsymmetricObject to the Realm.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
query<T extends RealmObject>(String query, [List<Object?> args = const []]) RealmResults<T>
Returns all RealmObjects that match the specified query.
refresh() bool
Update the Realm instance and outstanding objects to point to the most recent persisted version.
refreshAsync() Future<bool>
Returns a Future that will complete when the Realm is refreshed to the version which is the latest version at the time when this method is called.
toString() String
A string representation of this object.
inherited
write<T>(T writeCallback()) → T
Synchronously calls the provided callback inside a write transaction.
writeAsync<T>(T writeCallback(), [CancellationToken? cancellationToken]) Future<T>
Executes the provided writeCallback in a temporary write transaction. Both acquiring the write lock and committing the transaction will be done asynchronously.
writeCopy(Configuration config) → void
Writes a compacted copy of the Realm to the path in the specified config. If the configuration object has non-null Configuration.encryptionKey, the copy will be encrypted with that key.

Operators

operator ==(Object other) bool
The equality operator.
override

Static Methods

compact(Configuration config) bool
Compacts a Realm file. A Realm file usually contains free/unused space.
deleteRealm(String path) → void
Deletes all files associated with a Realm located at given path
exists(String path) Future<bool>
Checks whether a Realm exists at path.
existsSync(String path) bool
Synchronously checks whether a Realm exists at path
open(Configuration config, {CancellationToken? cancellationToken, ProgressCallback? onProgressCallback}) Future<Realm>
A method for asynchronously opening a Realm.
shutdown() → void
Used to shutdown Realm and allow the process to correctly release native resources and exit.

Constants

logger → const RealmLogger
The logger that will emit log messages from the database and sync operations. To receive log messages, use the RealmLogger.onRecord stream.