'use strict';
class Database {
constructor() {
this._sqlite3 = require('sqlite3').verbose();
this._conn = new this._sqlite3.Database(__dirname + '/database.sqlite');
}
findOne(sql, params) {
let self = this;
return self._conn.get(sql, params, function (err, row) {
if(err) throw err;
console.log(row);
return row;
})
}
'use strict';
class User extends Database {
constructor() {
super();
}
getWorker() {
let sql = 'select u.*, w.password from users u, workers w where u.id = w.user_id and u.type_id = ?';
return super.findOne(sql, [1]);
}
}
let user = new User();
console.log(user.getWorker()); // Приходит объект Database, хотя ожидаю Object просто