34 lines
841 B
JavaScript
34 lines
841 B
JavaScript
const {
|
|
Model
|
|
} = require('sequelize');
|
|
module.exports = (sequelize, DataTypes) => {
|
|
class Tag extends Model {
|
|
/**
|
|
* Helper method for defining associations.
|
|
* This method is not a part of Sequelize lifecycle.
|
|
* The `models/index` file will call this method automatically.
|
|
*/
|
|
static associate(models) {
|
|
/* define association here */
|
|
}
|
|
}
|
|
Tag.init({
|
|
tag_name: { type: DataTypes.STRING, allowNull: false, primaryKey: true }
|
|
}, {
|
|
sequelize,
|
|
timestamps: false,
|
|
modelName: 'Tag',
|
|
tableName: 'tag',
|
|
createdAt: true,
|
|
updatedAt: true
|
|
});
|
|
|
|
Tag.prototype.toJSONFor = function () {
|
|
return {
|
|
id: this.tag_id,
|
|
name: this.tag_name
|
|
};
|
|
};
|
|
|
|
return Tag;
|
|
}; |