File tree Expand file tree Collapse file tree 5 files changed +70
-0
lines changed Expand file tree Collapse file tree 5 files changed +70
-0
lines changed Original file line number Diff line number Diff line change 1+ node_modules
Original file line number Diff line number Diff line change 1+ const { app, BrowserWindow, ipcMain } = require ( "electron" )
2+
3+ var knex = require ( "knex" ) ( {
4+ client : "sqlite3" ,
5+ connection : {
6+ filename : "./database.sqlite"
7+ }
8+ } ) ;
9+
10+ app . on ( "ready" , ( ) => {
11+ let mainWindow = new BrowserWindow ( { height : 800 , width : 800 , show : false } )
12+ mainWindow . loadURL ( `file://${ __dirname } /main.html` )
13+ mainWindow . once ( "ready-to-show" , ( ) => { mainWindow . show ( ) } )
14+
15+ ipcMain . on ( "mainWindowLoaded" , function ( ) {
16+ let result = knex . select ( "FirstName" ) . from ( "User" )
17+ result . then ( function ( rows ) {
18+ mainWindow . webContents . send ( "resultSent" , rows ) ;
19+ } )
20+ } ) ;
21+ } ) ;
22+
23+
24+
25+ app . on ( "window-all-closed" , ( ) => { app . quit ( ) } )
Original file line number Diff line number Diff line change 1+ < html >
2+ < head >
3+ < title > </ title >
4+ < script >
5+ const electron = require ( "electron" ) ;
6+ const ipc = electron . ipcRenderer ;
7+ document . addEventListener ( "DOMContentLoaded" , function ( ) {
8+ ipc . send ( "mainWindowLoaded" )
9+ ipc . on ( "resultSent" , function ( evt , result ) {
10+ let resultEl = document . getElementById ( "result" ) ;
11+ console . log ( result ) ;
12+ for ( var i = 0 ; i < result . length ; i ++ ) {
13+ resultEl . innerHTML += "First Name: " + result [ i ] . FirstName . toString ( ) + "<br/>" ;
14+ }
15+ } ) ;
16+ } ) ;
17+ </ script >
18+ </ head >
19+ < body >
20+ < p id ="result "> </ p >
21+ </ body >
22+ </ html >
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " electron-test" ,
3+ "version" : " 1.0.0" ,
4+ "description" : " " ,
5+ "main" : " index.js" ,
6+ "scripts" : {
7+ "start" : " electron ." ,
8+ "rebuild" : " electron-rebuild -f -w sqlite3" ,
9+ "test" : " echo \" Error: no test specified\" && exit 1"
10+ },
11+ "keywords" : [],
12+ "author" : " " ,
13+ "license" : " ISC" ,
14+ "dependencies" : {
15+ "electron" : " ^1.6.6" ,
16+ "knex" : " ^0.13.0" ,
17+ "sqlite3" : " ^3.1.8"
18+ },
19+ "devDependencies" : {
20+ "electron-rebuild" : " ^1.5.7"
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments