Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
5001cem-DomesticRepairs/modules/uploadTrack.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
38 lines (28 sloc)
1.02 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sqlite = require('sqlite-async') | |
module.exports = class UploadTrack { | |
constructor(dbName = ':memory:') { | |
console.log("constructor") | |
return (async() => { | |
this.db = await sqlite.open(dbName) | |
const sql = 'CREATE TABLE IF NOT EXISTS uplorac\ | |
(id TEXT PRIMARY KEY , singer_name TEXT, singer_details TEXT, description TEXT,image_url TEXT, Track_name TEXT, trackSource TEXT);' | |
await this.db.run(sql) | |
return this | |
})() | |
} | |
async insert(id, singer_name, singer_details,description,track,image_url,src) { | |
const sql = `INSERT INTO uplorac(id, singer_name, singer_details,description,image_url,Track_name,trackSource) VALUES("${id}", "${singer_name}", "${singer_details}", "${description}", "${image_url}", "${track}","${src}")` | |
await this.db.run(sql) | |
console.log("Done") | |
return true | |
} | |
async getAll() { | |
const sql = `SELECT * FROM uplorac;` | |
const record = await this.db.all(sql) | |
console.log(record) | |
return record | |
} | |
async tearDown() { | |
await this.db.close() | |
} | |
} |