我在sequelizejs旁邊用es6使用node.js。node.js擴展foo不是函數
我的基類(base.js):
class base {
constructor(table) {
this._table = table;
}
all(query) {
this._table.findAll({
}).then(function (dbStatus) {
return new Promise((resolve, reject) => {
resolve(dbStatus);
})
});
};
}
我的派生類(city.js):派生類的
var util = require('util');
var base = new require('../base');
class city extends base {
constructor() {
super(db.city);
}
}
module.exports = city;
用法(cityrest.js):
var city = new require('../../dataBaseOperations/city')
var app = express();
app.get('/all', function (req, res, next) {
city.all(req.query, function (result, resultData) {
if (result) {
res.json({
data: {
success: result,
content: resultData,
message: 'messageContent'
}
});
}
})
})
錯誤是:TypeError:city.all不是cityrest.js的功能
這是'var base = new require('../ base');'真的有用嗎?如何暴露** Base ** - 代碼中沒有導出或module.exports。你可能想執行'var base = new(require('../ base'))'' –