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()

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. Listeners receive the document that was deleted as a parameter, allowing access to the data before it was removed.
final
onInsert Event<Map<String, Object?>>
Event triggered when a document is inserted into the collection. Listeners receive the complete inserted document as a parameter, including the generated _id field.
final
onUpdate Event<Map<String, Object?>>
Event triggered when a document is updated in the collection. Listeners receive the complete updated document as a parameter, with all current field values.
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