Пытаюсь вывести виртуальное поле, что я не так делаю?
const news = sequelize.define('news', {
id: {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true,
allowNull: false
},
title: {
type: Sequelize.STRING,
allowNull: false
},
content: {
type: Sequelize.TEXT,
allowNull: false
},
userId: {
type: Sequelize.INTEGER,
allowNull: false
},
date: {
type: Sequelize.DATE,
allowNull: false
},
reduct: {
type: Sequelize.VIRTUAL,
get: function() {
return `${ this.content.slice(0,50) }`;
}
}
},{
timestamps: false,
freezeTableName: true
});
news.findAll({raw: true, offset: offset, limit: limit, order: [['id', 'ASC']], include: {
model: models.db.user,
attributes: ['id', 'login']
}})
.then(news=>{
response.json(news)
})
Так же пробовал get() {
return `${ this.content.slice(0,50) }`;
}