Ryan Tran
Ryan Tran

Reputation: 487

mongodb - why name of collections alway is plural?

I use mongoose and schema in express js to create collection. I don's unserstand why name of collection alway is plural ? For example : i want to create "member" collection. After running, in my database, "members" collection is created. I re-checked many time to sure that name of collection which i code "member", not be "members". Did I miss anything ? Thanks advances!

Upvotes: 2

Views: 3308

Answers (1)

s7vr
s7vr

Reputation: 75924

From the docs, http://mongoosejs.com/docs/guide.html#collection

Mongoose by default use plurals for collection name.

Use collection option to set the name.

var memberSchema = new Schema({..}, { collection: 'member' });

Upvotes: 7

Related Questions