mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-30 07:05:24 +00:00
feat: look up local row ids by sync id for the sync plugin (Plugin-Sync#4)
This commit is contained in:
1 parent
691896db2d
commit
8d26c716b4
6 files changed
+54
-3
No files matched your search
@@ -112,6 +112,21 @@ export async function findStoredRow(
|
||||
return row ?? null;
|
||||
}
|
||||
|
||||
/** The local ids of the user's own rows, by sync id. Unknown ones are left out. */
|
||||
export async function findStoredIds(
|
||||
entity: RegisteredSyncEntity,
|
||||
userId: string,
|
||||
syncIds: string[],
|
||||
): Promise<Record<string, number>> {
|
||||
const ids: Record<string, number> = {};
|
||||
if (entity.singleton || !entity.table) return ids;
|
||||
for (const syncId of new Set(syncIds)) {
|
||||
const row = await findStoredRow(entity, userId, syncId);
|
||||
if (row && typeof row.id === "number") ids[syncId] = row.id;
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
/** Gives an old row with no syncId one, so it can take part. */
|
||||
async function ensureSyncId(
|
||||
entity: RegisteredSyncEntity,
|
||||
|
||||
Reference in new issue
Block a user