Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-1069

Enforcing unique values within a document

    • Type: Icon: Question Question
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Should it be possible to enforce uniqueness of an object within an array within a single document using a unique index?

      For instance:

      db.foo.save( { a : [

      { b : 1 }

      ] } )
      db.foo.ensureIndex({_id: 1, 'a.b': 1},

      {unique: true}

      );

      // This succeeds. Should it fail?
      db.foo.update({}, { '$push' : { 'a':

      {b: 1}

      } });

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            kbanker Kyle Banker
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: