Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion lib/mongo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ defmodule Mongo do
Convenient function that returns a cursor with the names of the indexes.
"""
@spec list_index_names(GenServer.server(), String.t(), Keyword.t()) ::
%Stream{} | {:error, Mongo.Error.t()}
{:ok, %Stream{}} | {:error, Mongo.Error.t()}
def list_index_names(topology_pid, coll, opts \\ []) do
list_indexes(topology_pid, coll, opts)
|> Stream.map(fn %{"name" => name} -> name end)
Expand Down
7 changes: 5 additions & 2 deletions test/mongo_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ defmodule Mongo.Test do
cmd = [createIndexes: coll_1, indexes: [[key: [foo: 1, bar: 1], name: "foo-bar"]]]
assert {:ok, _} = Mongo.command(c.pid, cmd)

{:ok, colls00}=
c.pid
Mongo.list_index_names(coll_1)

indexes =
c.pid
|> Mongo.list_index_names(coll_1)
colls00
|> Enum.to_list()

assert Enum.count(indexes) == 3
Expand Down