为什么我们添加'在收集名称之后我们想要放弃吗?

时间:2018-04-27 18:11:01

标签: javascript node.js mongoose

在这里,我想放弃我的收藏(MySQL中的表格),但我无法理解为什么我们要添加'到集合的名称,样本:
[集合名称(表格):myCollection]

const mongoose = require('mongoose');
 mongoose.connection.collections.myCollections.drop();

1 个答案:

答案 0 :(得分:0)

模型代表一个单一项目。集合是一堆独特的项目。 Mongoose会进行一些自动复数化,因此您必须深入了解如何自定义或调整它的文档。

根据他们的文档Mongoose by default produces a collection name by passing the model name to the utils.toCollectionName method. This method pluralizes the name. Set this option if you need a different name for your collection.

查看http://mongoosejs.com/docs/guide.html了解详情