Skip to content

Commit 284b338

Browse files
author
Bob Grabar
committed
DOCS-564 add more info on collection-naming conventions
1 parent 86241ca commit 284b338

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

source/release-notes/2.2.txt

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,9 @@ Behavioral Changes
306306
Restrictions on Collection Names
307307
````````````````````````````````
308308

309-
Collection names can no longer contain the ``$`` character.
309+
Collection names cannot contain the ``$`` character in version 2.2. The
310+
character is still allowed for collection names in MongoDB versions
311+
prior to 2.2.
310312

311313
The following is a full list of collection-name restrictions. Collection
312314
names can be any UTF-8 string with the following exceptions:
@@ -315,7 +317,7 @@ names can be any UTF-8 string with the following exceptions:
315317

316318
- The empty string ("") is not a valid collection name.
317319

318-
- Collection names cannot contain the ``$`` character.
320+
- Collection names cannot contain the ``$`` character. (version 2.2 only)
319321

320322
- Collection names cannot contain the null character: ``\0``
321323

@@ -327,6 +329,33 @@ names can be any UTF-8 string with the following exceptions:
327329
name of the db and indexes. A best practice is to keep your collection
328330
names below 80 characters.
329331

332+
If your collection name includes special characters, such as the
333+
underscore character, then to access the collection use the
334+
:method:`db.getCollection()` method or a similar :api:`method for your
335+
driver <>`.
336+
337+
.. example:: For example, to create a collection ``_foo`` and populate it
338+
with document ``{ a : 1 }``, you issue the following command:
339+
340+
.. code-block:: javascript
341+
342+
db.getCollection("_foo").insert( { a : 1 } )
343+
344+
To query the collection you issue the following command and get the
345+
following result:
346+
347+
.. code-block:: javascript
348+
349+
db.getCollection("_foo").find()
350+
{ "_id" : ObjectId("506dbf800f70bf70d1ca613b"), "a" : 1 }
351+
352+
You *cannot* query the ``_foo`` collection with this command:
353+
354+
.. code-block:: javascript
355+
356+
db._foo.find()
357+
Thu Oct 4 12:56:01 TypeError: db._foo has no properties (shell):1
358+
330359
Restrictions on Database Names for Windows
331360
``````````````````````````````````````````
332361

0 commit comments

Comments
 (0)