RealtimeCollectionReference<T> class

A handle for a named collection on a MongoRealtime server.

Use this reference to query and mutate documents in the collection.

Constructors

RealtimeCollectionReference({required MongoRealtime client, required String name, String? idField, FromJson<T>? fromJson})

Properties

hashCode → int
The hash code for this object.
no setterinherited
name → String
The collection name.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
stream → Stream<List<RealtimeDocument<T>>>
Subscribes to realtime updates for this collection.
no setter
streamWithValue → Stream<List<T>>
Subscribes to realtime updates for typed collection values.
no setter
watch ↔ DbWatcher
latefinal

Methods

delete({JsonMap? filter, bool optimistic = false}) → Future<void>
Deletes documents from the collection matching filter.
doc(String id, {String? idField}) → RealtimeDocumentReference<T>
Returns a reference to a single document by id.
find({JsonMap? filter, Map<String, int>? sort, int? limit}) → Future<List<RealtimeDocument<T>>>
Fetches the current documents matching the optional filter, sort, and limit.
insert(JsonMap document, {bool optimistic = false}) → Future<void>
Inserts a new document into the collection.
limit(int limit) → RealtimeQueryBuilder<T>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
or(void build(RealtimeQueryOrGroupBuilder group)) → RealtimeQueryBuilder<T>
Adds an $or clause to the query using the provided build callback.
query({JsonMap? filter, Map<String, int>? sort, int? limit}) → RealtimeQueryBuilder<T>
Creates a query builder for this collection.
sort(String field, {bool descending = false}) → RealtimeQueryBuilder<T>
take(int limit) → RealtimeQueryBuilder<T>
toString() → String
A string representation of this object.
inherited
update({JsonMap? $set, JsonMap? $unset, JsonMap? $inc, JsonMap? $push, JsonMap? $pull, JsonMap? $addToSet, JsonMap? $rename, JsonMap? additionalUpdate, JsonMap? filter, bool optimistic = false}) → Future<void>
Performs an update on all documents matching the query filter using MongoDB update operators. The update will be applied atomically on the server. If optimistic is true, the cache will be updated immediately with the expected changes, and then reconciled with the server response when it arrives. If optimistic is false, the cache will only be updated when the server confirms the update. The update parameter should be a map containing MongoDB update operators like $set, $unset, $inc, $push, $pull, $addToSet, and $rename.
where(String field, {Object? isEqualTo, Object? isNotEqualTo, Object? isGreaterThan, Object? isGreaterOrEqualTo, Object? isLowerThan, Object? isLowerOrEqualTo, Object? arrayContains, Iterable? isIn, Object? matches}) → RealtimeQueryBuilder<T>
Adds a filter clause to the query for the specified field.

Operators

operator ==(Object other) → bool
The equality operator.
inherited