ServiceWsDb class abstract
JSON-first contract for WebSocket-backed, NoSQL-like data access.
All methods and streams operate on Map<String, dynamic> payloads (JsonMap)
to standardize transport and simplify cross-layer contracts.
Error contracts
- All
collection/docIdMUST be non-empty → otherwise throws ArgumentError. - readDocument throws StateError if the document does not exist.
- documentStream remains open even if the document does not exist yet: implementations MAY either emit no events until creation or emit an error event and keep the stream open (document this behavior).
- collectionStream SHOULD emit an empty list when no documents exist and treat non-existent collections as empty.
Return contracts
- saveDocument SHOULD return the persisted document snapshot (server- normalized), including server timestamps/ids if applicable.
- deleteDocument SHOULD return an acknowledgment payload (e.g.,
{ 'ok': true }) or the last known snapshot if available; document the chosen strategy.
Call dispose to release resources and close underlying streams. Multiple calls to dispose SHOULD be no-ops.
- Implementers
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
collectionStream(
{required String collection}) → Stream< List< Map< >String, dynamic> > -
Stream realtime snapshots of all documents contained in
collection. -
deleteDocument(
{required String collection, required String docId}) → Future< Map< String, dynamic> > -
Delete a single document
docIdfromcollection. -
dispose(
) → void - Release resources and close underlying controllers/streams where applicable.
-
documentStream(
{required String collection, required String docId}) → Stream< Map< String, dynamic> > -
Stream realtime updates of a single document
docIdfromcollection. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
readDocument(
{required String collection, required String docId}) → Future< Map< String, dynamic> > -
Read a single document
docIdfromcollection. -
saveDocument(
{required String collection, required String docId, required Map< String, dynamic> document}) → Future<Map< String, dynamic> > -
Create or replace a document in
collectionidentified bydocIdwithdocument. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited