This is just a tiny observation, but I think it's worth pointing it out: Documents in MongoDB can never violate 'their own' unique value constraint. Let's look at an example:

> db.Test.getIndexes();
[
        // (snipped the _id index)
        {
                "v" : 1,
                "key" : {
                        "Keys" : 1
                },
                "unique" : true,
                "ns" : "test.Test",
                "name" : "Keys_1"
        }
]

As you can see, i have a unique key "Keys" in my "Test" collection. Now let's look at a simple insert:

> db.Test.insert({"Keys" : [1, 12]});

Fine, this worked. Let's add another one:

> db.Test.insert({"Keys" : [6, 8, 12]});
E11000 duplicate key error index: test.Test.$Keys_1  dup key: { : 12.0 }

Well, that was expected: the value '12' violates the unique constraint. How about this one:

> db.Test.insert({"Keys" : [2, 2]});
> db.Test.find()
{ "_id" : ObjectId("4edd4af9d9d4c41a519c9d33"), "Keys" : [ 1, 12 ] }
{ "_id" : ObjectId("4edd4b4ad9d4c41a519c9d38"), "Keys" : [ 2, 2 ] }
>

Yes, it worked! One might expect the insert to fail, because '2' is not 'unique'. However, an object can't violate itself by constraints, so to speak. I don't think this is too much of a surprise: If you searched for an object using

> db.Test.find({"Keys" : 2})
{ "_id" : ObjectId("4edd4b4ad9d4c41a519c9d38"), "Keys" : [ 2, 2 ] }

you'd expect to find exactly this document, and it is only matched once. In this sense, the behavior is fully consistent, but it's probably not what everybody expects.