import mongoose from 'mongoose'; const { Schema } = mongoose; const noteSchema = new mongoose.Schema({ parent: { type: Schema.Types.ObjectId, refPath: 'parentType', required: true, }, parentType: { type: String, required: true, }, content: { type: String, required: true, }, noteType: { type: Schema.Types.ObjectId, ref: 'noteType', required: true, }, createdAt: { type: Date, required: true, default: Date.now, }, updatedAt: { type: Date, required: true, default: Date.now, }, user: { type: Schema.Types.ObjectId, ref: 'user', required: false, }, }); noteSchema.virtual('id').get(function () { return this._id.toHexString(); }); noteSchema.set('toJSON', { virtuals: true }); export const noteModel = mongoose.model('note', noteSchema);