Categories
JavaScript Answers

How to get Schema of Node Mongoose database which defined in another model?

Spread the love

To get Schema of Node Mongoose database which defined in another model, we use the schema property.

For instance, we write

const SongSchema = require("mongoose").model("Song").schema;

to call the model method to get the 'Song' model.

And we use the schema property to get its schema.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *