full
This commit is contained in:
24
models/UserFollowModel.js
Normal file
24
models/UserFollowModel.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const mongoose = require('mongoose')
|
||||
const timestamp = require('mongoose-timestamp')
|
||||
|
||||
const userFollowSchema = new mongoose.Schema({
|
||||
followerId: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'User',
|
||||
required: true,
|
||||
index: true,
|
||||
},
|
||||
followingId: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'User',
|
||||
required: true,
|
||||
index: true,
|
||||
},
|
||||
})
|
||||
|
||||
userFollowSchema.index({ followerId: 1, followingId: 1 }, { unique: true })
|
||||
|
||||
userFollowSchema.plugin(timestamp)
|
||||
const UserFollowModel = mongoose.model('UserFollow', userFollowSchema)
|
||||
|
||||
module.exports = UserFollowModel
|
||||
Reference in New Issue
Block a user