无法从mongodb删除集合 [英] Can not delete collection from mongodb

查看:61
本文介绍了无法从mongodb删除集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法从外壳程序中删除集合,

Can not delete the collection from the shell,

集合可用的东西,我的php脚本正在访问它(选择|更新)

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

但是当我使用时:

db._registration.drop()

它给我一个错误:

Date, JS Error: TypeErrorL db._registration has no properties (shell): 1

推荐答案

问题不在于删除集合.问题在于访问集合.因此,您将无法从外壳程序对其进行更新,查找或执行任何操作.正如 mongodb JIRA 中所指出的那样,当集合中包含如下字符时,这是一个错误_-.

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 .

尽管如此,这种类型的集合名称还是可以接受的,但这会在shell中引起问题.

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()

或这个

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).

这篇关于无法从mongodb删除集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆