gpt4 book ai didi

node.js - Sequelize 抛出 [object SequelizeInstance : tablename] error

转载 作者:行者123 更新时间:2023-12-03 22:28:57 26 4
gpt4 key购买 nike

当我尝试将记录添加到我的数据库时,我在浏览器上看到了 [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;

模型.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;

最佳答案

您正在使用 express response sendStatus 方法,该方法需要 http 状态的整数。代码 res.send(jane) 可能就是您正在寻找的。

关于node.js - Sequelize 抛出 [object SequelizeInstance : tablename] error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33316257/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com