Reputation: 3533
I'd like to create a data access object where I can pass a database name, say:
var Dao = require('./dao')
mydb = new Dao('sample_database');
mydb.append('hello')
any idea how to do this? thanks
Upvotes: 1
Views: 63
Reputation: 1691
I have created minimal solution from what I understand.
doa.js
let Dao = function(dbName) {
console.log(dbName);
}
Dao.prototype.append = function (text) {
console.log("append " + text)
}
module.exports = Dao;´
main.js
let Dao = require('./dao');
let daoInstance = new Dao('testName');
daoInstance.append("apple");
Let me know if it helps.
Upvotes: 3