Spaces:
Running
Running
File size: 578 Bytes
71601b1 c4341fd 71601b1 c4341fd 71601b1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | const mongoose = require('mongoose');
const PinSchema = new mongoose.Schema({
message_id: { type: mongoose.Schema.Types.ObjectId, ref: 'Message' },
chat_id: { type: String, index: true },
pinner_id: { type: String },
pin_type: { type: String, enum: ['both', 'me', 'self'], default: 'both' },
text_preview: { type: String },
timestamp: { type: Date, default: Date.now }
});
PinSchema.index({ chat_id: 1, pinner_id: 1 });
PinSchema.index({ message_id: 1, chat_id: 1, pinner_id: 1 }, { unique: true });
module.exports = mongoose.model('Pin', PinSchema);
|