Preview:
import { Model, model, models, Schema, Types } from "mongoose";

export interface MessageType {
    messageBody: string,
    creator: Types.ObjectId
    id: string
    _id: Types.ObjectId
  label: "AI" | "Human"
}
const messageSchema= new Schema({
    messageBody: String,
    creator: {
        type: Types.ObjectId,
        ref: "User"
    },
  label: String

    },
    {
        timestamps: true,
        toJSON: {
            virtuals: true,
        },
        toObject: {
            virtuals: true,
        },
    }
    
)
const Message= (models.Message || model("Message", messageSchema)) as Model<MessageType>;
export default Message;
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter