-
Notifications
You must be signed in to change notification settings - Fork 1.7k
DOCS-651 migrate collections page #411
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| =========== | ||
| Collections | ||
| =========== | ||
|
|
||
| .. default-domain:: mongodb | ||
|
|
||
| MongoDB :term:`collections` are named groupings of documents. You can | ||
| think of them as roughly equivalent to relational database tables. | ||
|
|
||
| A MongoDB collection is a collection of :term:`BSON` :term:`documents | ||
| <document>`. MongoDB is a schema-free database and does not predefine a | ||
| collection's fields. The documents within a collection may or may not | ||
| have the same structure. Any new document can add new fields to a | ||
| collection. | ||
|
|
||
| Collections can be created explicitly using the | ||
| :method:`db.createCollection()` method but can also be created | ||
| implicitly by specifying a new collection name when creating a document | ||
| using the :method:`insert() <db.collection.insert()>` method. | ||
|
|
||
| Collection Names | ||
| ---------------- | ||
|
|
||
| A collection name can be any UTF-8 string that follows these standards: | ||
|
|
||
| - Collection names should begin with a letter or an underscore (_). | ||
|
|
||
| - Collection names can include numbers. | ||
|
|
||
| - Collection names *cannot* include the ``$`` character, which is a | ||
| reserved character. | ||
|
|
||
| - Collection names *cannot* include the null character. | ||
|
|
||
| - Collection names *cannot* be an empty string (e.g. ``""``). | ||
|
|
||
| - Collection names *cannot* begin with the ``system.`` prefix, which is | ||
| reserved for system collections. | ||
|
|
||
| - The maximum size of a collection name is 128 characters, including the | ||
| name of the database. However, for maximum flexibility, collections | ||
| should have names less than 80 characters. | ||
|
|
||
| Collections can be organized by namespaces. Namespaces are named groups | ||
| of collections defined using a dot notation. For example, the | ||
| collections ``blog.posts`` and ``blog.authors`` are in the ``blog`` | ||
| namespace. | ||
|
|
||
| Namespaces are an organizational method for the database user and do not | ||
| imply an underlying organizational structure in the database itself. | ||
| From database perspective, there is no relationship between collections | ||
| in the same namespace. | ||
|
||
|
|
||
| View a List of Collections | ||
| -------------------------- | ||
|
|
||
| From the :program:`mongo` shell, you can view list of collections in a | ||
| database using the method:`getCollectionNames() | ||
| <db.getCollectionNames()>` method. | ||
|
|
||
| Query a Collection | ||
| ------------------ | ||
|
|
||
| From the :program:`mongo` shell, you can query a collection's documents | ||
| using the MongoDB :method:`find() <db.collection.find()>` and | ||
| :method:`findOne() <db.collection.findOne()>` methods. For more | ||
| information, see :doc:`/applications/read`. | ||
|
|
||
| If your collection name begins with an underscore, then to query the | ||
| collection's documents from the :program:`mongo` shell you must use the | ||
| :method:`getCollection() <db.getCollection()>` method along with the | ||
| query operator (e.g. :method:`find() <db.collection.find()>`). | ||
|
|
||
| Though underscores are allowed at the beginnings of collection names, | ||
| the :program:`mongo` shell considers the underscore character to be a | ||
| javascript value, not a collection name. The :method:`getCollection() | ||
| <db.getCollection()>` method gets around this. Consider the following example: | ||
|
|
||
| .. code-block:: javascript | ||
|
|
||
| db.getCollection( "_mycollection" ).find() | ||
|
||
|
|
||
| Capped Collections | ||
| ------------------ | ||
|
|
||
| MongoDB includes a special type of collection, called a :term:`capped | ||
| collection`, that is used for certain high-throughput operations, such | ||
| as journaling. See :doc:`/core/capped-collections`. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 24-42 are redundant to: http://docs.mongodb.org/manual/reference/limits/#Restriction%20on%20Collection%20Names (if there are oversights in that section we should edit that...)