MappingStateRepository
Repository for mapping state and record hash tracking. Implements spec Section 7.5.2 - Tracking Tables.
public static class MappingStateRepository
Methods
GetMappingState(SqliteConnection, string)
public static Result<MappingStateEntry?, SyncError> GetMappingState(SqliteConnection connection, string mappingId)
Gets mapping state by ID.
Parameters:
| Name | Type | Description |
|---|---|---|
connection |
SqliteConnection |
SQLite connection. |
mappingId |
String |
Mapping identifier. |
Returns: SyncError> - Mapping state or null if not found.
GetAllMappingStates(SqliteConnection)
public static Result<IReadOnlyList<MappingStateEntry>, SyncError> GetAllMappingStates(SqliteConnection connection)
Gets all mapping states.
Parameters:
| Name | Type | Description |
|---|---|---|
connection |
SqliteConnection |
SQLite connection. |
Returns: SyncError> - List of mapping states.
UpsertMappingState(SqliteConnection, MappingStateEntry)
public static Result<bool, SyncError> UpsertMappingState(SqliteConnection connection, MappingStateEntry state)
Upserts a mapping state entry.
Parameters:
| Name | Type | Description |
|---|---|---|
connection |
SqliteConnection |
SQLite connection. |
state |
MappingStateEntry |
State to upsert. |
Returns: SyncError> - Success or error.
DeleteMappingState(SqliteConnection, string)
public static Result<bool, SyncError> DeleteMappingState(SqliteConnection connection, string mappingId)
Deletes a mapping state entry.
Parameters:
| Name | Type | Description |
|---|---|---|
connection |
SqliteConnection |
SQLite connection. |
mappingId |
String |
Mapping identifier to delete. |
Returns: SyncError> - Success or error.
GetRecordHash(SqliteConnection, string, string)
public static Result<RecordHashEntry?, SyncError> GetRecordHash(SqliteConnection connection, string mappingId, string sourcePk)
Gets record hash for hash-based sync tracking.
Parameters:
| Name | Type | Description |
|---|---|---|
connection |
SqliteConnection |
SQLite connection. |
mappingId |
String |
Mapping identifier. |
sourcePk |
String |
Source primary key JSON. |
Returns: SyncError> - Record hash entry or null.
UpsertRecordHash(SqliteConnection, RecordHashEntry)
public static Result<bool, SyncError> UpsertRecordHash(SqliteConnection connection, RecordHashEntry entry)
Upserts a record hash entry.
Parameters:
| Name | Type | Description |
|---|---|---|
connection |
SqliteConnection |
SQLite connection. |
entry |
RecordHashEntry |
Hash entry to upsert. |
Returns: SyncError> - Success or error.
DeleteRecordHashesForMapping(SqliteConnection, string)
public static Result<int, SyncError> DeleteRecordHashesForMapping(SqliteConnection connection, string mappingId)
Deletes record hashes for a mapping.
Parameters:
| Name | Type | Description |
|---|---|---|
connection |
SqliteConnection |
SQLite connection. |
mappingId |
String |
Mapping identifier. |
Returns: SyncError> - Number of deleted records or error.
GetMinSyncedVersion(SqliteConnection)
public static Result<long, SyncError> GetMinSyncedVersion(SqliteConnection connection)
Gets the minimum last_synced_version across all active mappings. Used for tombstone retention calculation.
Parameters:
| Name | Type | Description |
|---|---|---|
connection |
SqliteConnection |
SQLite connection. |
Returns: SyncError> - Minimum version or 0 if no mappings.