Update index.js

This commit is contained in:
2024-11-27 22:52:27 +00:00
parent af5ca4de67
commit 8fe2e9236c

View File

@@ -1,11 +1,16 @@
const initSqlJs = window.initSqlJs;
config = {
locateFile: filename => `/dist/${filename}`
}
const initSqlJs = window.initSqlJs
const SQL = await initSqlJs({
// Required to load the wasm binary asynchronously. Of course, you can host it wherever you want
// You can omit locateFile completely when running in node
locateFile: file => `https://sql.js.org/dist/${file}`
});
// Create a database
const db = new SQL.Database();
const { createApp, ref } = Vue
//filters module
@@ -19,9 +24,32 @@ const { createApp, ref } = Vue
},
methods(){
methods:{
sqlStatements(opt, val = 0){
var stmt;
switch(opt){
case 0:
stmt = "SELECT * FROM index";
break;
case 1:
stmt = "SELECT DISTINCT lga FROM index";
break;
case 2:
stmt = "SELECT DISTINCT crime_category FROM index";
break;
case 3:
stmt = "SELECT record_id FROM index";
case 4:
stmt = db.prepare("SELECT * FROM records WHERE record_id=:id");
stmt = stmt.
default:
break;
}
return stmt;
} ,
init(){
db.exec(sqlStatements(0))
}
},
@@ -29,4 +57,4 @@ const { createApp, ref } = Vue
this.init;
}
}, {"dbConnObj": db).mount('#filters');
}, {"dbConnObj": db}).mount('#filters');