I said 'as I expected', because I might be misunderstanding how it should work.

I have a model containing objects like this one :

```json
{
    "_id" : ObjectId("56408d76ef82679937000008"),
    "_type" : "ford",
    "year" : 1986,
    "model" : "sierra",
    "model_unique" : 1,
    "__v" : 0
}

```

I need a compound unique index that will not allow to insert two objects with the same `_type` and `model` combination unless specified.

The way I thought I could specify that, was using the `model_unique` column and make the index sparse, so adding the former document twice should fail, whereas the following should be allowed (note that there is no `model_unique` field):

```json
{
    "_id" : ObjectId("56408e0d636779c83700000a"),
    "_type" : "veridianDynamics",
    "year" : 1986,
    "model" : "sierra",
    "__v" : 0
}
{
    "_id" : ObjectId("another ID"),
    "_type" : "veridianDynamics",
    "year" : 2003,
    "model" : "sierra",
    "__v" : 0
}

```

I thought this would work with this index:

```js
Schema.index({"_type": 1, "model": 1, "model_unique": 1}, { unique: true, sparse: true });

```

But it is actually failing with:

```
[MongoError: insertDocument :: caused by :: 11000 E11000 duplicate key error index: mongoose-schema-extend.vehicles.$_type_1_model_1_model_unique_1  dup key: { : "veridianDynamics", : "sierra", : null }]

```

So apparently it is considering that the undefined fields have a null value.

I'm using `mongod --version
db version v2.6.11`

And `npm -v mongoose
2.14.4`