Skip to content

DOCS-564 added collection-naming conventions #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 4, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions source/release-notes/2.2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,52 @@ See: :issue:`SERVER-6961` for more information.
Behavioral Changes
~~~~~~~~~~~~~~~~~~

Restrictions on Collection Names
````````````````````````````````

In version 2.2, collection names cannot contain the ``$`` character. The
character is still allowed for collection names in MongoDB versions
prior to 2.2.

The following is a full list of collection-name restrictions. Collection
names can be any UTF-8 string with the following exceptions:

- A collection name should begin with a letter or an underscore.

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

- Collection names cannot contain the ``$`` character. (version 2.2 only)

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

- Do not name a collection using the ``system.`` prefix. The ``system.``
prefix is reserved for system collections, such as the
``system.indexes`` collection.

- The maximum size of a collection name is 128 characters, including the
name of the db and indexes. A best practice is to keep your collection
names below 80 characters.

If your collection name includes special characters, such as the
underscore character, then to access the collection use the
:method:`db.getCollection()` method or a :api:`similar method for your
driver <>`.

.. example:: To create a collection ``_foo`` and populate it with
document ``{ a : 1 }``, you would issue the following command:

.. code-block:: javascript

db.getCollection("_foo").insert( { a : 1 } )

To query the collection, you would issue the following command and
get the following result:

.. code-block:: javascript

db.getCollection("_foo").find()
{ "_id" : ObjectId("506dbf800f70bf70d1ca613b"), "a" : 1 }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omit the final example.

Restrictions on Database Names for Windows
``````````````````````````````````````````

Expand Down