Realm class Realm
A Realm instance represents a Realm
database.
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
Methods
-
add<
T extends RealmObject> (T object, {bool update = false}) → T -
Adds a
RealmObject
to theRealm
. -
addAll<
T extends RealmObject> (Iterable< T> items, {bool update = false}) → void -
Adds a collection
RealmObject
s to thisRealm
. -
all<
T extends RealmObject> () → RealmResults< T> -
Returns all
RealmObject
s of typeT
in theRealm
-
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 thisRealm
. -
deleteAll<
T extends RealmObject> () → void -
Deletes all
RealmObject
s of typeT
in theRealm
-
deleteMany<
T extends RealmObject> (Iterable< T> items) → void -
Deletes many
RealmObject
s from thisRealm
. -
disableAutoRefreshForTesting(
) → void -
find<
T extends RealmObject> (Object? primaryKey) → T? -
Fast lookup for a
RealmObject
with the specifiedprimaryKey
. -
freeze(
) → Realm - Returns a frozen (immutable) snapshot of this 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
RealmObject
s that match the specifiedquery
. -
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 givenpath
-
exists(
String path) → Future< bool> -
Checks whether a
Realm
exists atpath
. -
existsSync(
String path) → bool -
Synchronously checks whether a
Realm
exists atpath
-
open(
Configuration config, {CancellationToken? cancellationToken}) → 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 SDK operations. To receive log messages, use the RealmLogger.onRecord stream.