For some small applications that use SQLite Database, I needed to design a small library to simplify my work. And connect to the database without any worries. So I also published the library that I implemented for the projects here.
const database = require(`./database`)
database.open(`database.db`)
database.run(`CREATE TABLE IF NOT EXISTS 'record'
(
ID INTEGER PRIMARY KEY NOT NULL,
meetingId CHAR(70) NOT NULL,
recordId CHAR(70) NOT NULL,
status INTEGER NOT NULL
)`)
database.update(`UPDATE langs SET name = ? WHERE name = ?`, [`test`, `c`])
database.delete(`DELETE FROM langs WHERE rowid=?`, [1])
database.insert(`INSERT INTO langs(name) VALUES(?)`, [4])
database.selects(`SELECT * FROM record WHERE status = 0 ORDER BY ID ASC LIMIT 5`, [],
(rows) => {
console.log(rows)
for(let row of rows) {
console.log(row)
}
})
database.select(`SELECT * FROM record WHERE meetingId = ? AND recordId = ?`, [5, 8], (res) => {
console.log(res)
})
database.select(`SELECT COUNT(*) as count FROM record WHERE meetingId = ? AND recordId = ?`, [5, 8], (res) => {
if(res[`count`]) {
console.log(res[`count`])
} else {
console.log(`Error: ${res}`)
}
})
database.close()
- Adding example js files
- Publish package to npm package manager
I appreciate if anyone does these and send PR to me.
My nickname is Max, Programming language developer, Full-stack programmer. I love computer scientists, researchers, and compilers.
A team includes some programmer, developer, designer, researcher(s) especially Max Base.