var fs = require('fs');
var SQL = require('sql.js');
var filebuffer = fs.readFileSync('./resources/app.asar/app/data/sample.db');
var db = new SQL.Database(filebuffer);
function save_data(){
var name=document.getElementById('name').value;
var ip=document.getElementById('serverip').value;
var result=db.each("UPDATE Settings SET Name=$name, IP=$ip WHERE SettingsId=$set",{$name:name,$ip : ip,$set:1},function(row){console.log(row.name)});
var data = db.export();
var buffer = new Buffer(data);
fs.writeFileSync('./resources/app.asar/app/data/sample.db', buffer);
}
I was able to read the data from the database file inside the asar archive, but while writing the data into db file, it doesn't gets updated inside asar archive. So please help me crack this issue.
Asar is a read-only archive. It just concatenates all the files together into a single blob.