sqlite3 multithreading nodejs

Solutions on MaxInterview for sqlite3 multithreading nodejs by the best coders in the world

showing results for - "sqlite3 multithreading nodejs"
Stefania
11 Jun 2019
1const cluster = require('cluster');
2const db = new sqlite3.Database(':memory:')
3
4if (cluster.isMaster) {
5    console.log(`Master ${process.pid} is running`);
6    cluster.fork()
7        .on('exit', (worker, code, signal) => {
8            console.log(`worker ${worker.process.pid} died`);
9        });
10    cluster.fork()
11        .on('exit', (worker, code, signal) => {
12            console.log(`worker ${worker.process.pid} died`);
13        });
14
15} else if (cluster.worker.id === 1){
16  db.run(QUERY1);
17} else {
18 db.run(QUERY2);
19}
20