23 lines
537 B
TypeScript
23 lines
537 B
TypeScript
import { db, type ImportedPoolRow } from "@/src/db/appDb";
|
|
|
|
const DEFAULT_USER_ID = "anon";
|
|
|
|
function key(userId: string) {
|
|
return `${userId}:imported_pool`;
|
|
}
|
|
|
|
export async function getImportedPool(userId = DEFAULT_USER_ID) {
|
|
return db.importedPool.get(key(userId));
|
|
}
|
|
|
|
export async function setImportedPool(codesText: string, userId = DEFAULT_USER_ID) {
|
|
const row: ImportedPoolRow = {
|
|
id: key(userId),
|
|
userId,
|
|
codesText,
|
|
updatedAt: new Date().toISOString(),
|
|
};
|
|
await db.importedPool.put(row);
|
|
return row;
|
|
}
|