这两个猫鼬模式在导出时有什么区别?

what is the difference between these 2 mongoose schemas while exporting them?

下面是我项目中一个用户配置文件的架构。

 var agencyProfile = mongoose.Schema({
      name: {
        type: String
      },
      user: {
        type: mongoose.Schema.ObjectId,
        ref: "users"
      }
    })

我想知道这两个导出的模式有什么区别?

 module.exports = mongoose.model('agencyProfile', agencyProfile);
    vs
module.exports = mongoose.model('agencyProfile', agencyProfile, "agencyProfile");

第三个参数基本上允许您将集合名称(默认情况下从模型名称推断)更改为其他名称。来自 documentation:

When no collection argument is passed, Mongoose uses the model name. If you don't like this behavior, either pass a collection name, use mongoose.pluralize(), or set your schemas collection name option.

在您的情况下,这没有任何区别,因为集合名称与模型名称匹配 agencyProfile