Skip to content

Commit 64507f3

Browse files
authored
DOCSP-41551: dropone() return type (#370)
* DOCSP-41551: dropone return type * add whats new item * tense * PV tech review comment
1 parent 5348430 commit 64507f3

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

source/fundamentals/indexes.txt

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -440,31 +440,20 @@ The following example creates a unique, descending index on the ``theaterId`` fi
440440
Remove an Index
441441
---------------
442442

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

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

450-
.. io-code-block::
451-
:copyable: true
452-
453-
.. input::
454-
:language: go
455-
456-
coll := client.Database("sample_mflix").Collection("movies")
457-
res, err := coll.Indexes().DropOne(context.TODO(), "title_1")
458-
if err != nil {
459-
panic(err)
460-
}
461-
fmt.Println(res)
462-
463-
.. output::
464-
:language: none
465-
:visible: false
450+
.. code-block:: go
466451

467-
{"nIndexesWas": {"$numberInt":"2"}}
452+
coll := client.Database("sample_mflix").Collection("movies")
453+
err := coll.Indexes().DropOne(context.TODO(), "title_1")
454+
if err != nil {
455+
panic(err)
456+
}
468457

469458
Additional Information
470459
----------------------

source/whats-new.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ The 2.0 {+driver-short+} release includes the following improvements and fixes:
8787
- The ``Distinct()`` method returns a struct that can be decoded into a
8888
specified type. See the :ref:`golang-retrieve-distinct` guide to learn more.
8989

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

9297
What's New in 1.16

0 commit comments

Comments
 (0)