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

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

  realm.write(() => {
    realm.create(dbName, value as any, Realm.UpdateMode.Modified);
  });
};
