1

This strange problem. I use mongoose to create a schema and model and ,then save something into database. Because this is a new collections. mongodb create the collection automatical. But I find that the collections name is diffrent to the definiton in mongoose model function.

Example: In Script: chessMD = mogoose.model("chessDB",chessSchema);

but in mongodb client After I use show collections, the collection name is chessdbs;

anyone know the reason?

1 Answers1

0

By default Mongoose will automatically create a collection name by pluralizing the name of the model. See http://mongoosejs.com/docs/api.html#index_Mongoose-model

If however you want to force a specific collection name you can do that too. See Mongoose -- Force collection name for answers.

Community
  • 1
  • 1
Moiz Raja
  • 5,612
  • 6
  • 40
  • 52