import mongoose from "mongoose"; const { Schema } = mongoose; const noteSchema = new mongoose.Schema({ parent: { type: Schema.Types.ObjectId, 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);