Local Sync & Delete Log Utils
These functions handle internal tracking of the last sync and delete operations for each table in your local SQLite database. Supastash relies on this metadata to decide what to pull, push, or clean up during sync.
β οΈ For development and debugging only β avoid using them in production.
π€ setLocalSyncLog(tableName: string, lastSyncedAt: string)
β
Sets the sync timestamp for a given table.
await setLocalSyncLog("users", new Date().toISOString());
π₯ getLocalSyncLog(tableName: string)
β
Retrieves the sync log for a given table.
const syncLog = await getLocalSyncLog("users");
/*
{
table_name: "users",
lastSyncedAt: "2024-06-01T10:00:00.000Z"
}
*/
Returns null
if the table has no recorded sync log.
π§Ή clearLocalSyncLog(tableName: string)
β
Deletes the sync log for a specific table.
await clearLocalSyncLog("users");
π clearAllLocalSyncLog()
β
Clears all sync logs table.
await clearAllLocalSyncLog();
β οΈ Warning: This clears sync history for all tables. Use with caution (e.g., in dev resets).
π setLocalDeleteLog(tableName: string, lastDeletedAt: string)
β
Sets the lastest deleted timestamp for a given table.
await setLocalDeleteLog("users", new Date().toISOString());
π getLocalDeleteLog(tableName: string)
β
Retrieves the delete log for a given table.
const deleteLog = await getLocalDeleteLog("users");
/*
{
table_name: "users",
lastDeletedAt: "2024-06-01T10:00:00.000Z"
}
*/
Returns null
if the table has no delete checkpoint.
π§Ό clearLocalDeleteLog(tableName: string)
β
Deletes the delete log for a specific table.
await clearLocalDeleteLog("users");
β clearAllLocalDeleteLog()
β
Drops the entire delete log table.
await clearAllLocalDeleteLog();
β οΈ Warning: This wipes all delete history for all tables.