You can get the Mongoose schema
object from a Mongoose model
simply by accessing the schema
property on it, for example, like so:
import { model } from 'mongoose';
const schema = model('name_of_model').schema;
This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.