@@ -306,7 +306,9 @@ Behavioral Changes
306
306
Restrictions on Collection Names
307
307
````````````````````````````````
308
308
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.
310
312
311
313
The following is a full list of collection-name restrictions. Collection
312
314
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:
315
317
316
318
- The empty string ("") is not a valid collection name.
317
319
318
- - Collection names cannot contain the ``$`` character.
320
+ - Collection names cannot contain the ``$`` character. (version 2.2 only)
319
321
320
322
- Collection names cannot contain the null character: ``\0``
321
323
@@ -327,6 +329,33 @@ names can be any UTF-8 string with the following exceptions:
327
329
name of the db and indexes. A best practice is to keep your collection
328
330
names below 80 characters.
329
331
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
+
330
359
Restrictions on Database Names for Windows
331
360
``````````````````````````````````````````
332
361
0 commit comments