full
This commit is contained in:
22
models/CommentLikeModel.js
Normal file
22
models/CommentLikeModel.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const mongoose = require('mongoose')
|
||||
const timestamp = require('mongoose-timestamp')
|
||||
|
||||
const commentLikeSchema = new mongoose.Schema({
|
||||
commentId: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'Comment',
|
||||
required: true,
|
||||
index: true,
|
||||
},
|
||||
userId: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'User',
|
||||
required: true,
|
||||
index: true,
|
||||
},
|
||||
})
|
||||
|
||||
commentLikeSchema.index({ commentId: 1, userId: 1 }, { unique: true })
|
||||
commentLikeSchema.plugin(timestamp)
|
||||
|
||||
module.exports = mongoose.model('CommentLike', commentLikeSchema)
|
||||
Reference in New Issue
Block a user