import {getDatabase} from './getDB.web';
import {databaseConf, possibleDBKeys} from './types';

export const getEntry = async <T2 extends databaseConf<T>, T>(
  schema: T2,
  key: possibleDBKeys,
): Promise<null | T> => {
  const dbName = schema.details.name;
  const db = await getDatabase(dbName);

  const tx = db.transaction(dbName, 'readonly');
  const store = tx.objectStore(dbName);

  return await store.get(key);
  //await store.put(value);
  //await tx.done;
};
