MongoDB WriteError “code” : 9

两盒软妹~` 提交于 2019-12-13 06:58:02

问题


I am trying to delete some records from MongoDB that have dirty values, but whenever I try to delete it, I am getting the writeError with code 9.

A sample of the dirty document is as follows:

{
    "_id" : "some_unique_id_abcd",
    "tmp" : "1415772407377",
    "hiv" : "0.0",
    "liv" : "0.0",
    "oindx" : "0.0"
}

The remove command executed is as follows:

db.myCollection.remove({"_id" : "some_unique_id_abcd"});

The following error is thrown

WriteResult({
    "writeError" : {
        "code" : 9,
        "errmsg" : "wrong type for 'delete' field, expected string, 
                    found delete: 0.0"
    }
})

Any idea what exactly this error is about or how to get around it?


回答1:


This is what the error code means:

error_code("FailedToParse", 9)



回答2:


From the capped collection docs that BatScream linked:

You cannot delete documents from a capped collection. To remove all records from a capped collection, use the ‘emptycapped’ command. To remove the collection entirely, use the drop() method.

Documents expire from the capped collection as new documents are inserted. You cannot manually delete documents. See the docs for more info and warnings about capped collections.



来源:https://stackoverflow.com/questions/26966437/mongodb-writeerror-code-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!