DEV Community

Discussion on: Building a RESTful API with NestJS and MongoDB (Mongoose)

Collapse
 
babytoy profile image
Ian Bautista

Ang galing nito Miguel, thanks for writing the article.

How do I force the schema to use a collection name?

Collapse
 
carlomigueldy profile image
Carlo Miguel Dy

Thank you po Ian! Happy that you enjoyed reading it!

Collapse
 
babytoy profile image
Ian Bautista • Edited

OK na Miguel, I figured it out.
@Schema({ collection: 'collection name' })

Mongoose will pluralize the collection name from the schema name unless explicitly declared like this.

Collapse
 
riyas145 profile image
Riyas Ahamed

thanks i also have same doubt but you cleared now

Collapse
 
carlomigueldy profile image
Carlo Miguel Dy

Sounds good! Thanks Ian 🎉