Can not delete collection from mongodb

前端 未结 3 1170
甜味超标
甜味超标 2021-01-01 12:36

Can not delete the collection from the shell,

The thing that the collection is available and my php script is accessing it (selecting|updating)

But when I us

3条回答
  •  误落风尘
    2021-01-01 13:13

    The problem is not with deleting the collection. The problem is with accessing the collection. So you would not be able to update, find or do anything with it from the shell. As it was pointed in mongodb JIRA, this is a bug when a collection has characters like _, - or .

    Nevertheless this type of names for collections is acceptable, but it cause a problem in shell.

    You can delete it in shell with this command:

    db.getCollection("_registration").drop()
    

    or this

    db['my-collection'].drop()
    

    but I would rather rename it (of course if it is possible and will not end up with a lot of changing).

提交回复
热议问题