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

export const setEntry = async <T2 extends databaseConf<T>, T>(
  schema: T2,
  value: T,
) => {
  const dbName = schema.details.name;
  const db = await getDatabase(dbName);

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

  await store.put(value);
  await tx.done;
};
