[refactor] s/fed_user/ap_user

This commit is contained in:
les
2019-12-04 01:20:31 +01:00
parent c43fe095a5
commit 5052ceca0a
17 changed files with 214 additions and 123 deletions

View File

@@ -0,0 +1,18 @@
module.exports = (sequelize, DataTypes) => {
const APUser = sequelize.define('ap_user', {
ap_id: {
type: DataTypes.STRING,
primaryKey: true
},
follower: DataTypes.BOOLEAN,
blocked: DataTypes.BOOLEAN,
object: DataTypes.JSON
})
APUser.associate = function (models) {
APUser.belongsTo(models.instance)
APUser.hasMany(models.resource)
}
return APUser
}

View File

@@ -1,16 +0,0 @@
module.exports = (sequelize, DataTypes) => {
const fed_users = sequelize.define('fed_users', {
ap_id: {
type: DataTypes.STRING,
primaryKey: true
},
blocked: DataTypes.BOOLEAN,
object: DataTypes.JSON
}, {})
fed_users.associate = function (models) {
fed_users.belongsTo(models.instances)
fed_users.belongsToMany(models.user, { through: 'user_followers', as: 'followers' })
fed_users.hasMany(models.comment, { foreignKey: 'fedUserApId' })
}
return fed_users
}

View File

@@ -1,6 +1,6 @@
'use strict'
module.exports = (sequelize, DataTypes) => {
const instances = sequelize.define('instances', {
const Instance = sequelize.define('instance', {
domain: {
primaryKey: true,
allowNull: false,
@@ -11,9 +11,9 @@ module.exports = (sequelize, DataTypes) => {
data: DataTypes.JSON
}, {})
instances.associate = function (models) {
instances.hasMany(models.fed_users)
Instance.associate = function (models) {
Instance.hasMany(models.ap_user)
}
return instances
return Instance
}

View File

@@ -1,6 +1,6 @@
'use strict'
module.exports = (sequelize, DataTypes) => {
const notification = sequelize.define('notification', {
const Notification = sequelize.define('notification', {
filters: DataTypes.JSON,
email: DataTypes.STRING,
remove_code: DataTypes.STRING,
@@ -19,9 +19,9 @@ module.exports = (sequelize, DataTypes) => {
}]
})
notification.associate = function (models) {
notification.belongsToMany(models.event, { through: 'event_notification' })
Notification.associate = function (models) {
Notification.belongsToMany(models.event, { through: 'event_notification' })
// associations can be defined here
}
return notification
return Notification
}

View File

@@ -1,6 +1,7 @@
'use strict'
module.exports = (sequelize, DataTypes) => {
const place = sequelize.define('place', {
const Place = sequelize.define('place', {
name: {
type: DataTypes.STRING,
unique: true,
@@ -10,9 +11,9 @@ module.exports = (sequelize, DataTypes) => {
address: DataTypes.STRING
}, {})
place.associate = function (models) {
place.hasMany(models.event)
Place.associate = function (models) {
Place.hasMany(models.event)
}
return place
return Place
}

View File

@@ -1,6 +1,6 @@
'use strict'
module.exports = (sequelize, DataTypes) => {
const tag = sequelize.define('tag', {
const Tag = sequelize.define('tag', {
tag: {
type: DataTypes.STRING,
allowNull: false,
@@ -10,9 +10,9 @@ module.exports = (sequelize, DataTypes) => {
weigth: { type: DataTypes.INTEGER, defaultValue: 0, allowNull: false }
}, {})
tag.associate = function (models) {
tag.belongsToMany(models.event, { through: 'event_tags' })
Tag.associate = function (models) {
Tag.belongsToMany(models.event, { through: 'event_tags' })
}
return tag
return Tag
}