Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-209

ensureIndex differs from native mongoDB spec

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.4.8
    • Affects Version/s: 1.4, 1.4.8
    • Component/s: None
    • Labels:

      In mongoDB shell when you execute a db.ensureIndex() command it will return an error obj if the index already exists but has a differing spec than the one specified.

      example in shell

      db.foo.ensureIndex(

      { foo : 1 }

      );

      "createdCollectionAutomatically" : false,
      "numIndexesBefore" : 1,
      "numIndexesAfter" : 2,
      "ok" : 1
      }
      db.foo.ensureIndex(

      { foo : 1 }

      ,

      { unique : true }

      );
      {
      "ok" : 0,
      "errmsg" : "Index with name: foo_1 already exists with different options",
      "code" : 85
      }

      In the current node driver, if you execute a collection.ensureIndex() it does not return an error if the index differs from the desired index options. This means in Node there isn't a pathway to determine if there is a conflicting index state. Could ensureIndex be modified so that it returns an error on differing options?

            Assignee:
            christkv Christian Amor Kvalheim
            Reporter:
            owenallenaz Owen Allen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: