An example app integrating Electron.js with Mikro-ORM. The Electron.js app is scaffolded using electron-vite.
MikroORM uses so called MetadataProvider to get necessary type information about our entities' properties. In this project we use TsMorphMetadataProvider
as metadata provider, its process can be performance heavy and time-consuming. For this reason, metadata cache is automatically generated and stored inside ./temp
folder to JSON files. 1
However, in Electron.js the app gets bundled using Vite into a single JavaScript file, therefore we need to deploy only the compiled output, without TS source files at all. In order to do that, we genrate cache bundle file which can be used together with GeneratedCacheAdapter
.
In order to create new migrations you need to follow these steps:
- Generate new metadata cache (This command will generate new metadata json file in the
temp
folder located in the project root)
yarn cache:generate
- Generate a new migration
yarn migration:create
- Remove existing migrations by deleting your
migrations
folder - Ensure you drop the existing database if it was previously created
- Remove or comment out the import of
metadata.json
frommikro-orm-shared.config.ts
if you haven't created your first metadata cache yet. - Generate new metadata cache
yarn cache:generate
- Generate the initial migration
yarn migration:create-init
$ yarn
$ yarn dev
# For windows
$ yarn build:win
# For macOS
$ yarn build:mac
# For Linux
$ yarn build:linux
If you have any questions or suggestions, please feel free to open a new issue.
I would appreciate a ⭐ if this repository has been helpful to you in any way.