【问题标题】:mongodb - why name of collections alway is plural?mongodb - 为什么集合的名称总是复数?
【发布时间】:2017-05-18 05:52:24
【问题描述】:

我在 express js 中使用猫鼬和模式来创建集合。 我不明白为什么集合的名称总是复数? 例如:我想创建“成员”集合。运行后,在我的数据库中,创建了“成员”集合。我重新检查了很多次,以确保我编码为“成员”的集合名称,而不是“成员”。 我错过了什么吗? 感谢进步!

【问题讨论】:

    标签: mongoose


    【解决方案1】:

    来自文档,http://mongoosejs.com/docs/guide.html#collection

    Mongoose 默认使用复数作为集合名称。

    使用集合选项设置名称。

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

    【讨论】:

      猜你喜欢
      • 2021-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-19
      • 2018-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多