Skip to content

Commit

Permalink
DOCSP-41551: dropone() return type (#370)
Browse files Browse the repository at this point in the history
* DOCSP-41551: dropone return type

* add whats new item

* tense

* PV tech review comment
  • Loading branch information
rustagir authored Jul 22, 2024
1 parent 5348430 commit 64507f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
29 changes: 9 additions & 20 deletions source/fundamentals/indexes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -440,31 +440,20 @@ The following example creates a unique, descending index on the ``theaterId`` fi
Remove an Index
---------------

You can remove any unused index except the default unique index on the
You can delete any index from a collection except the default unique index on the
``_id`` field. To remove an index, pass the name of your index to the
``DropOne()`` method.

The following example removes an ascending index on the ``title`` field
in the ``sample_mflix.movies`` collection:
The following example removes an index called ``title_1``
from the ``sample_mflix.movies`` collection:

.. io-code-block::
:copyable: true

.. input::
:language: go

coll := client.Database("sample_mflix").Collection("movies")
res, err := coll.Indexes().DropOne(context.TODO(), "title_1")
if err != nil {
panic(err)
}
fmt.Println(res)

.. output::
:language: none
:visible: false
.. code-block:: go

{"nIndexesWas": {"$numberInt":"2"}}
coll := client.Database("sample_mflix").Collection("movies")
err := coll.Indexes().DropOne(context.TODO(), "title_1")
if err != nil {
panic(err)
}

Additional Information
----------------------
Expand Down
5 changes: 5 additions & 0 deletions source/whats-new.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ The 2.0 {+driver-short+} release includes the following improvements and fixes:
- The ``Distinct()`` method returns a struct that can be decoded into a
specified type. See the :ref:`golang-retrieve-distinct` guide to learn more.

- The ``IndexView.DropOne()`` method returns only an error, if present. In
previous versions, this method also returned the server response, which
contained the number of dropped indexes. See the
:ref:`golang-remove-index` section of the Indexes guide to learn more.

.. _version-1.16:

What's New in 1.16
Expand Down

0 comments on commit 64507f3

Please sign in to comment.