Sfoglia il codice sorgente

Add Notification and MentionNotification models

sbkwgh 8 anni fa
parent
commit
8f911ef329
2 ha cambiato i file con 29 aggiunte e 0 eliminazioni
  1. 13 0
      models/MentionNotification.js
  2. 16 0
      models/Notification.js

+ 13 - 0
models/MentionNotification.js

@@ -0,0 +1,13 @@
+module.exports = (sequelize, DataTypes) => {
+	let MentionNotification = sequelize.define('MentionNotification', {}, {
+		classMethods: {
+			associate (models) {
+				Notification.belongsTo(models.User)
+				Notification.belongsTo(models.Post)
+				Notification.belongsTo(models.Notification)
+			}
+		}
+	})
+
+	return MentionNotification
+}

+ 16 - 0
models/Notification.js

@@ -0,0 +1,16 @@
+module.exports = (sequelize, DataTypes) => {
+	let Notification = sequelize.define('Notification', {
+		title: DataTypes.TEXT,
+		read: DataTypes.BOOLEAN,
+		type: DataTypes.ENUM('mention', 'thread update') 
+	}, {
+		classMethods: {
+			associate (models) {
+				Notification.hasOne(models.MentionNotification, { as: 'Data' })
+				Notification.belongsTo(models.User)
+			}
+		}
+	})
+
+	return Notification
+}