Files
modstagram-back/models/CommentLikeModel.js
payacom 3f416a7a60 full
2026-08-31 20:45:41 +03:30

23 lines
544 B
JavaScript

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)