在这里,我想放弃我的收藏(MySQL中的表格),但我无法理解为什么我们要添加'到集合的名称,样本:
[集合名称(表格):myCollection]
const mongoose = require('mongoose');
mongoose.connection.collections.myCollections.drop();
答案 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.