What is third parameter in mongoose.model? What is use of it

505 Views Asked by At

const db = mongoose.model('User', userSchema, 'user')

What is use of that third parameter? Where can we use that parameter. What is use of that parameter. Any practical example

1

There are 1 best solutions below

1
Shubham On

The third parameter is an explicit collection name.

Once I faced this use case , we had client and he want to have a prefix for each collection name when it get created in db ,something like "apple_users" , in that case it was useful