POC for Electron app with Vue 3 frontend and persisted database with SQlite.
Inside project root folder
note: I prefer using yarn as npm is highly unstable with electron and vue integration
yarn 
yarn electron:serveTo Build App for OS executables
yarn electron:build- The project is a normal Vue CLI project. So the file structure is pretty familiar.
- The electron builder plugin adds a new file src/background.ts, this serves as the entry point of the electron app.
- src/data.dbIn project SQlite 3 database for testing.
- getdb.tsInitiates the Sequelize instance for using the database.
- main.tsentry of vue app. It creates the vue instance and mounts the app.
- For adding pages/views for electron app go to > src/views.
- For adding components to be used i Vue pages/views go to > src/components
- To create new app window / or any electron stuff go to > src/background.ts
- For working with database i.e. creating models for sequelize go to > src/getdb.ts
- tsconfig.jsonfor configuring typescript.
- vue.config.jsVue config. Not recommended to change anything in this file.
- Sequelize is a promise based ORM. So using it is pretty easy.
- Whe using sequelize we don't have to create tables as it creates and syncs tables according to the defined models.
- Sequelize models are a abstaction of the data schema or the table schema of a db. So instead of using SQL queries for creating tables we can make sequelize to do that by using models.
- A sample model Useris defined insrc/getdb.ts. Learn more about sequelize Models
// a sample model USer
const User = sequelize.define('User', {
    firstName: {
        type: DataTypes.STRING,
        allowNull: false
    },
    lastName: {
        type: DataTypes.STRING
    },
}, {
});- SQL queries are replaced by sequelize model queries .
// sample query for model User
// inside an async function
User.findAll().then((res)=>{
	console.log(res)
}).catch(err=> console.log(err))Lean more about model Queries here
- More about Sequelize can be found in their Docs. Not that good but functional.
- Usage with Vuex is not recommended as it causes the db process to stop on reload.
- There are no known bugs as the build was successful with no errors.
- To report a bug create an issue.
For errors try googling or contact me!