Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1455

Checking for the existence of an index is very verbose

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor - P4
    • Resolution: Unresolved
    • Affects Version/s: 2.0, 2.1
    • Fix Version/s: None
    • Component/s: API
    • Labels:
      None

      Description

      This is a request for a 'HasIndex(string indexName)' or 'ContainsIndex(string indexName)' helper.

      Unless I'm missing something, to find out if an index exists on a collection, one must:

      var query = await myCollection.Indexes.ListAsync();
      var bsonIndexes = await query.ToListAsync();
      var indexNames = bsonIndexes .Select(i => i.Values); // or some variation
      return indexNames.Contains("blah");

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            nick@innsenroute.com Nick Judson
            Participants:
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: