CollectionEvent class

Event management system for database collection operations.

This class provides event handling capabilities for database operations, allowing you to register listeners that are called when documents are inserted, updated, or deleted from a collection.

Each event type supports both synchronous and asynchronous listeners, making it flexible for various use cases such as:

  • Logging database operations
  • Triggering side effects (like sending notifications)
  • Maintaining data consistency across related collections
  • Caching updates

Example:

collection.collectionEvent.onInsert.addListener((document) {
  print('New document inserted: ${document['_id']}');
});

collection.collectionEvent.onUpdate.addAsyncListener((document) async {
  await updateSearchIndex(document);
});

Constructors

CollectionEvent.new()

Properties

hashCode int
The hash code for this object.
no setterinherited
onDelete Event<Map<String, Object?>>
Event triggered when a document is deleted from the collection.
final
onInsert Event<Map<String, Object?>>
Event triggered when a document is inserted into the collection.
final
onUpdate Event<Map<String, Object?>>
Event triggered when a document is updated in the collection.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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