当我尝试将记录添加到我的数据库中时,我在浏览器上看到[object SequelizeInstance:feed]
。它将记录添加到数据库中,但它显示了此文本。
为什么会发生这种情况?如何防止它?
我的代码出了什么问题?
这是我的db.js
var Sequelize = require('sequelize');
var sequelize = new Sequelize('mydatabasename', 'root', 'root', {
host: 'localhost',
dialect: 'mysql',
port: 8889,
pool: {
max: 5,
min: 0,
idle: 10000
},
define: {
timestamps: false
}
});
var db = {};
db.sequelize = sequelize;
db.Sequelize = Sequelize;
module.exports = db;
models.js
var feed = sequelize.define('feed', {
subscriber_id: Sequelize.INTEGER,
activity_id: Sequelize.INTEGER
},
{
tableName: 'feeds',
freezeTableName: true
});
module.exports.feed = feed;
路由/ index.js
var express = require('express');
var router = express.Router();
var db = require('../db'),
sequelize = db.sequelize,
Sequelize = db.Sequelize;
var feed = require('../models').feed;
router.get('/addfeed', function(req,res) {
sequelize.sync().then(function () {
return feed.create({
subscriber_id: 5008,
activity_id : 116
});
}).then(function (jane) {
res.sendStatus(jane);
});
});
module.exports = router;