import mongoose from 'mongoose'; import { generateId } from '../../utils.js'; const { Schema } = mongoose; const userNotifierSchema = new mongoose.Schema({ _reference: { type: String, default: () => generateId()() }, user: { type: Schema.Types.ObjectId, ref: 'user', required: true, }, email: { type: Boolean, required: true, default: false, }, object: { type: Schema.Types.ObjectId, refPath: 'objectType', required: true, }, objectType: { type: String, required: true, }, createdAt: { type: Date, required: true, default: Date.now, }, updatedAt: { type: Date, required: true, default: Date.now, }, }); userNotifierSchema.virtual('id').get(function () { return this._id; }); userNotifierSchema.set('toJSON', { virtuals: true }); export const userNotifierModel = mongoose.model('userNotifier', userNotifierSchema);