Mise à jour de routes et models
This commit is contained in:
+20
-31
@@ -1,34 +1,23 @@
|
||||
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
|
||||
});
|
||||
const { DataTypes, Model } = require("sequelize");
|
||||
const sequelize = require("../util/database");
|
||||
|
||||
Tag.prototype.toJSONFor = function () {
|
||||
return {
|
||||
id: this.tag_id,
|
||||
name: this.tag_name
|
||||
};
|
||||
const Tag = sequelize.define("Tag", {
|
||||
name: { type: DataTypes.STRING, primaryKey: true, allowNull: false },
|
||||
createdAt: { type: DataTypes.DATE, allowNull: true },
|
||||
updatedAt: { type: DataTypes.DATE, allowNull: true }
|
||||
}, {
|
||||
sequelize,
|
||||
timestamps: false,
|
||||
modelName: 'Tag',
|
||||
tableName: 'tag',
|
||||
createdAt: true,
|
||||
updatedAt: true
|
||||
});
|
||||
|
||||
Tag.prototype.toJSONFor = function () {
|
||||
return {
|
||||
name: this.name
|
||||
};
|
||||
};
|
||||
|
||||
return Tag;
|
||||
};
|
||||
module.exports = Tag;
|
||||
|
||||
Reference in New Issue
Block a user