From 2144e4114ff0ad08ceeeee86fa3d29cec23460ac Mon Sep 17 00:00:00 2001 From: jeff-allen-mongo Date: Tue, 5 Oct 2021 14:56:12 -0400 Subject: [PATCH] Revert "DOCSP-14047 add note about mongoshell to page" This reverts commit c0967545403116e58c9b26ab5693c39c41264cb8. --- source/faq/fundamentals.txt | 44 ++++++------------- .../reference/method/db.createCollection.txt | 3 -- 2 files changed, 14 insertions(+), 33 deletions(-) diff --git a/source/faq/fundamentals.txt b/source/faq/fundamentals.txt index 320b6188f2e..bbede4711b1 100644 --- a/source/faq/fundamentals.txt +++ b/source/faq/fundamentals.txt @@ -44,51 +44,35 @@ the columns in a relational database table. How do I create a database and a collection? -------------------------------------------- -.. note:: - - You can enter the commands referenced in this FAQ by using - the :binary:`MongoDB Shell <~bin.mongo>`. The MongoDB Shell is an - interactive JavaScript interface to MongoDB. You can use the MongoDB - Shell to query and update data as well as perform administrative - operations. - If a database does not exist, MongoDB creates the database when you first store data for that database. If a collection does not exist, MongoDB creates the collection when you -first store data for that collection. +first store data for that collection. [#explicit-creation]_ As such, you can switch to a non-existent database (``use ``) and perform the following operation: .. code-block:: javascript - use myNewDB; - - db.myNewCollection1.insertOne( { x: 1 } ); - db.myNewCollection2.createIndex( { a: 1 } ); + use myNewDB -- The :method:`db.collection.insertOne()` method creates - the collection ``myNewCollection1`` if it does not already exist. + db.myNewCollection1.insertOne( { x: 1 } ) + db.myNewCollection2.createIndex( { a: 1 } ) -- The :method:`db.collection.createIndex()` method creates the index and - the collection ``myNewCollection2`` if it does not already exist. +The ``insert`` operation creates both the database ``myNewDB`` and the +collection ``myNewCollection1`` if they do not already exist. -- If the ``myNewDb`` database did not exist, either the - :method:`db.collection.createIndex()` method or - :method:`db.collection.insertOne()` method would have created - the ``myNewDb`` database automatically. - -You can also create a collection explicitly using -:method:`db.createCollection` method if you want to specify specific -:ref:`options`, such as maximum size -or document validation rules: - -.. code-block:: javascript +The ``createIndex`` operation, which occurs after the ``myNewDB`` has +been created, creates the index and the collection ``myNewCollection2`` +if the collection does not exist. If ``myNewDb`` did not exist, the +``createIndex`` operation would have also created the ``myNewDB``. - use myNewDB; +.. [#explicit-creation] - db.createCollection("myNewCollection1"); + You can also create a collection explicitly using + :method:`db.createCollection` if you want to specify specific + options, such as maximum size or document validation rules. .. _faq-schema-free: diff --git a/source/reference/method/db.createCollection.txt b/source/reference/method/db.createCollection.txt index b0e7879424e..2887f02ab01 100644 --- a/source/reference/method/db.createCollection.txt +++ b/source/reference/method/db.createCollection.txt @@ -57,9 +57,6 @@ Definition } ) - - .. _create_collection_parameters: - The :method:`db.createCollection()` method has the following parameters: