PostgresDataStorageAdapter class

PostgreSQL-backed implementation of IDataStorageAdapter.

Filters, sorting and pagination compile to SQL; a filter this adapter cannot express is rejected as an invalid argument rather than quietly falling back to filtering in Dart. The one exception is RecordFilter.containsTerms, which becomes LOWER(payload::text) LIKE '%term%' — a full scan with a JSONB-to-text cast per row that no index can serve. Use searchCollection (FTS) when the collection is large enough for that to matter.

Optimistic concurrency is preserved via version-aware upserts.

Implemented types

Properties

enableChangeJournal bool
final
executor → Session
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
schema String
final
schemaRegistry PostgresSchemaRegistry
final
tablePrefix String
final

Methods

createCollectionIndex(CreateCollectionIndexRequest request) Future<CollectionIndex>
override
deleteCollection(String collection) Future<bool>
override
deleteCollectionIndex(DeleteCollectionIndexRequest request) Future<bool>
override
deleteRecord(String collection, String id, {int? expectedVersion}) Future<bool>
override
deleteRecords(String collection, Iterable<String> ids) Future<int>
override
dispose() Future<void>
override
ensureReady({bool validateIntegrity = true}) Future<void>
Ensure the underlying storage is initialised and ready to serve traffic.
override
listCollections() Future<List<String>>
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
queryCollection(ListRecordsRequest request) Future<ListRecordsResponse>
Execute a filtered query over a collection, applying sort and pagination directly in the storage backend. Implementations should throw an RpcDataError when the requested filter or sort is not supported.
override
readCollection(String collection) Future<List<DataRecord>>
override
readCollectionChunks(String collection, {int chunkSize = BaseDataRepository.databaseExportChunkSize}) Stream<List<DataRecord>>
override
readRecord(String collection, String id) Future<DataRecord?>
override
readRecords(String collection, Iterable<String> ids) Future<Map<String, DataRecord>>
override
searchCollection(SearchRecordsRequest request) Future<SearchRecordsResponse>
Execute a search query against the backend, applying the provided filter and pagination options at the storage layer. Implementations should throw an RpcDataError when the request cannot be executed.
override
toString() String
A string representation of this object.
inherited
writeRecord(DataRecord record) Future<void>
override
writeRecords(Iterable<DataRecord> records) Future<void>
override

Operators

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

Static Methods

connect({required Endpoint endpoint, ConnectionSettings? settings, String schema = 'public', String tablePrefix = '', bool enableFts = false, bool enableChangeJournal = true, PostgresIntegrityReporter? onIntegrityIssue}) Future<PostgresDataStorageAdapter>
withPool(Pool pool, {String schema = 'public', String tablePrefix = '', bool enableFts = false, bool enableChangeJournal = true, PostgresIntegrityReporter? onIntegrityIssue}) Future<PostgresDataStorageAdapter>