|
@@ -15,6 +15,21 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
Post.belongsTo(models.Thread)
|
|
|
Post.hasMany(models.Post, { as: 'Replies' })
|
|
|
Post.hasOne(models.Post, { as: 'ReplyingTo' })
|
|
|
+ },
|
|
|
+ includeOptions () {
|
|
|
+ let models = sequelize.models
|
|
|
+
|
|
|
+ return [
|
|
|
+ { model: models.User, attributes: ['username', 'createdAt', 'id'] },
|
|
|
+ { model: models.Thread, include: [models.Category]} ,
|
|
|
+ {
|
|
|
+ model: models.Post, as: 'ReplyingTo', include:
|
|
|
+ [{ model: models.User, attributes: ['username', 'id'] }]
|
|
|
+ }, {
|
|
|
+ model: models.Post, as: 'Replies', include:
|
|
|
+ [{ model: models.User, attributes: ['username', 'id'] }]
|
|
|
+ }
|
|
|
+ ]
|
|
|
}
|
|
|
}
|
|
|
})
|