错误:创建索引时出错:不允许用户执行操作[createIndex]

时间:2019-12-18 07:39:16

标签: mongodb mongoose mongodb-atlas

您好,我正在使用MongoDB Atlas云数据库以及以下软件包:

  • mongodb:“ ^ 3.4.0”,
  • 猫鼬:“ ^ 5.8.1”,
  • 节点:12.13.1

我遇到以下错误:

!!! 错误:创建索引时出错:不允许用户对[dinotribe-dev.system.indexes]执行操作[createIndex] !!!

"Error: Error creating index: user is not allowed to do action [createIndex]"

我尝试过:

1)使用内置的“ Admin”和“ ReadWriteAnyDatabase”特权。我还创建了自定义特权。没有一个工作。

2)删除了mongoose.set('useCreateIndex',true),但是随后我收到了关于sureIndex的弃用警告。

3)我尝试从以下架构中删除唯一键:

const LessonSchema = new mongoose.Schema({
  courseNumber: { type: String, unique: true, index: true },
  lessonProps: [],
  rewardProps: [],
  websiteReward: {},
  lessonOutline: {},
  FeedbackTemplates:{},
});

我还有其他几种模式,但是上面引用索引的唯一模式。

任何帮助将不胜感激。

谢谢!

0 个答案:

没有答案
相关问题