且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

猫鼬放什么东西?

更新时间:2023-11-28 23:16:58

使用Mongoose时的默认集合名称是小写的,复数的模型名称.

The default collection name when using Mongoose is the lower-cased, pluralized model name.

因此,如果您要按以下方式为ProfileSchema创建模型:

So if you're creating your model for the ProfileSchema as:

var ProfileModel = mongoose.model('Profile', ProfileSchema);

集合名称为profiles;因此您会在外壳程序中找到它的内容为db.profiles.find().

the collection name is profiles; so you'll find its contents as db.profiles.find() in the shell.

请注意,如果您不喜欢默认行为,则可以提供自己的集合名称作为mongoose.model的第三个参数:

Note that you can provide your own collection name as the third parameter to mongoose.model if you don't like the default behavior:

var ProfileModel = mongoose.model('Profile', ProfileSchema, 'MyProfiles');

将定位到名为MyProfiles的集合.