InMemoryTable<T> class

A map-backed table of records, keyed by id and stored as their JSON row.

This is the whole storage story a backend needs: one map from id to the row toJson() produced, decoded with fromJson() on the way out. Keeping the row as the wire form (rather than the entity) is the point — an adapter built this way stores what the model round-trips, and a record written before a field existed still parses.

Implemented types

Constructors

InMemoryTable({required T decode(Map<String, dynamic> json), required Map<String, dynamic> encode(T entity), required String idOf(T entity)})
Creates an empty InMemoryTable.

Properties

decode → T Function(Map<String, dynamic> json)
Reads a record back from its row.
final
encode → Map<String, dynamic> Function(T entity)
Writes a record to its row.
final
hashCode → int
The hash code for this object.
no setterinherited
idOf → String Function(T entity)
The id a record is stored under.
final
rows → Map<String, Map<String, dynamic>>
The rows, keyed by record id.
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

all() → List<T>
Every record, in insertion order.
find(String id) → T?
The record under id, or null when the table holds none.
has(String id) → bool
Whether the table holds id.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
put(T entity) → void
Stores entity under its own id, replacing whatever row was there.
remove(String id) → bool
Removes id; true when a row was there to remove.
replaceAll(Map<String, Map<String, dynamic>> rows) → void
Replaces every row — how a rollback restores a snapshot.
override
snapshot() → Map<String, Map<String, dynamic>>
A copy of every row — what a transaction keeps to undo itself.
override
toString() → String
A string representation of this object.
inherited

Operators

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