所以我在用mongo开发一个项目,执行代码后出现错误:db.usercollection.insert({ "username" : "testuser1", "email" : "[email protected]" })
显示的错误是:

Cannot use 'commands' readMode, degrading to 'legacy' mode WriteResult({
        "writeError" : {
                "code" : 13,
                "errmsg" : "not authorized on watersheds to execute command { insert: \"usercollection\", documents: [ { _id: ObjectId('568d0eda45d472b121116bef'), username: \"testuser1\", email: \"[email protected]\" } ], ordered: true }"
        } })

db.version()是3.0.7,我安装的MongoDB Shell版本是3.2.0

我该如何解决?

问候,
达里尔

最佳答案

db.getCollection(collectionName).count({});
db.getCollection(collectionName).find({});

有用!也许mongo需要其他操作。

07-28 09:21