|
@@ -1,7 +1,21 @@
|
|
|
-const { DataTypes } = require('sequelize');
|
|
|
-const sequelize = require('./index').sequelize;
|
|
|
+'use strict';
|
|
|
+const {
|
|
|
+ Model
|
|
|
+} = require('sequelize');
|
|
|
|
|
|
-const Contact = sequelize.define('Contact', {
|
|
|
+module.exports = (sequelize, DataTypes) => {
|
|
|
+ class Contact 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
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Contact.init({
|
|
|
id: {
|
|
|
type: DataTypes.INTEGER,
|
|
|
primaryKey: true,
|
|
@@ -50,20 +64,23 @@ const Contact = sequelize.define('Contact', {
|
|
|
defaultValue: false,
|
|
|
comment: '是否已发送邮件通知'
|
|
|
}
|
|
|
-}, {
|
|
|
- tableName: 'contacts',
|
|
|
- timestamps: true,
|
|
|
- indexes: [
|
|
|
- {
|
|
|
- fields: ['email']
|
|
|
- },
|
|
|
- {
|
|
|
- fields: ['status']
|
|
|
- },
|
|
|
- {
|
|
|
- fields: ['createdAt']
|
|
|
- }
|
|
|
- ]
|
|
|
-});
|
|
|
-
|
|
|
-module.exports = Contact;
|
|
|
+ }, {
|
|
|
+ sequelize,
|
|
|
+ modelName: 'Contact',
|
|
|
+ tableName: 'contacts',
|
|
|
+ timestamps: true,
|
|
|
+ indexes: [
|
|
|
+ {
|
|
|
+ fields: ['email']
|
|
|
+ },
|
|
|
+ {
|
|
|
+ fields: ['status']
|
|
|
+ },
|
|
|
+ {
|
|
|
+ fields: ['createdAt']
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ });
|
|
|
+
|
|
|
+ return Contact;
|
|
|
+};
|