Details
-
Improvement
-
Resolution: Done
-
Major - P3
-
None
-
2.0.1
-
None
-
None
-
ALL
Description
In the http://www.mongodb.org/display/DOCS/Collections
Collection names should begin with letters or an underscore and may include numbers; $ is reserved.
Use $ in name:
> db.dropDatabase()
|
> db.createCollection("$test")
|
{ "ok" : 1 }
|
> db.getCollectionNames()
|
[ "system.indexes"]
|
> db.createCollection("$test")
|
{ "errmsg" : "collection already exists", "ok" : 0 }
|
Use UTF-8 characters when creating collection:
> db.getCollectionNames()
|
[ "system.indexes" ]
|
> db.createCollection("имя")
|
{
|
"errmsg" : "exception: invalid ns: query-test.имя.$_id_",
|
"code" : 10094,
|
"ok" : 0
|
}
|
> db.getCollectionNames()
|
[ "system.indexes", "имя" ]
|
Use UTF-8 characters when renaming collection:
> db.dropDatabase()
|
{ "dropped" : "query-test", "ok" : 1 }
|
> db.createCollection("tmp")
|
{ "ok" : 1 }
|
> db.tmp.renameCollection("имя")
|
{ "ok" : 1 }
|
> db.getCollectionNames()
|
[ "system.indexes", "имя" ]
|
Inserting into collection with name in UTF-8:
> db.ИМЯ.insert({"test":1})
|
invalid ns: query-test.ИМЯ
|
> db["ИМЯ"].insert({"test":1})
|
invalid ns: query-test.ИМЯ
|
Dropping collection with name in UTF-8:
> db.ИМЯ.drop()
|
false
|
> db.getCollectionNames()
|
[ "system.indexes", "имя" ]
|
In Java, Python and PHP it is impossible to create collection with name in UTF-8, but it's possible to use such characters in rename and drop.