MongoDB error: Cannot use 'commands' readMode, degrading to 'legacy' mode

dgnebres picture dgnebres · Jan 6, 2016 · Viewed 13.6k times · Source

So I was developing a project using mongo and I got an error after executing the code: db.usercollection.insert({ "username" : "testuser1", "email" : "[email protected]" })

The error displayed was:

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 }"
        } })

The db.version() is 3.0.7 and I installed MongoDB shell version is 3.2.0

How should I fix this?

Regards, Daryll

Answer

Geraint picture Geraint · Jun 5, 2017
db.getCollection(collectionName).count({});
db.getCollection(collectionName).find({});

It works! maybe mongo needs other operation.