import Realm from 'realm';
import DBSchemas from './schemas';

export const initDatabase = (): Promise<void> => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      for (const key in DBSchemas) {
        const Schema = DBSchemas[key as keyof typeof DBSchemas];
        Realm.open({
          schema: [Schema.details],
          schemaVersion: Schema.version,
          path: Schema.filePath,
        });
      }
      resolve();
    }, 1000);
  });
};
