注意这里fileData的数据很长
post:
后端:
但是数据库中没有该数据
如有同样问题,可以看下自己的表结构:
我是这里的问题,
解决:
停掉nodemon,
modele更改为:
fileData: {
//这里需要很长的数据长度
type: DataTypes.TEXT,
allowNull: true,
comment: '文章的内容'
},
强制同步一遍,注意同步后表中的数据会丢失:
markdownFile.sync({
force:true})
当然你也可以在表结构中直接更改为TEXT
完整代码
const {
DataTypes
} = require('sequelize')
const seq = require('../db/seq')
const markdownFile = seq.define('markdownFile', {
file_id: {
type: DataTypes.INTEGER,
allowNull: true,
comment: '文章的id'
},
author: {
type: DataTypes.STRING,
allowNull: false,
comment: '文章的作者'
},
file_name: {
type: DataTypes.STRING,
allowNull: false,
comment: '文章名字'
},
category: {
type: DataTypes.STRING,
allowNull: true,
comment: '文章的简略'
},
fileData: {
//这里需要很长的数据长度
type: DataTypes.TEXT,
allowNull: true,
comment: '文章的内容'
},
views: {
type: DataTypes.INTEGER,
allowNull: true,
comment: '文章的浏览量'
},
create_time: {
type: DataTypes.TIME,
allowNull: true,
comment: '文章的创建时间'
},
tag1: {
type: DataTypes.STRING,
allowNull: true,
comment: '文章的tag1'
},
tag2: {
type: DataTypes.STRING,
allowNull: true,
comment: '文章的tag2'
},
})
// markdownFile.sync({force:true})
module.exports = markdownFile