first commit
This commit is contained in:
22
src/repositories/importedPoolRepo.ts
Normal file
22
src/repositories/importedPoolRepo.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user