strongloop/loopback-connector-mongodb — pull request #66 by amenadiel (2014-11-12 16:48:29+00:00)
Title: allows for different kind of indexes

Let's say you had a mongodb model with properties

```
"properties" : {
"id": {
"type": "String",
"required": false,
"id": 1
},
"geometry": {
"type": "Object",
"required": false,
"index": {
"unique": true
}
}
};
```

when you run autoupdate on this model, it will execute

```
db[collection].ensureIndex({"geometry":1},{"unique":true});
```
the **1** (which stands for a regular index in natural order) is hardcoded. This pull request let's you create other kind of indexes

For example, to create a ["2dsphere" index](http://docs.mongodb.org/manual/tutorial/build-a-2dsphere-index/), the model properties should be

```
"properties" : {
"id": {
"type": "String",
"required": false,
"id": 1
},
"geometry": {
"type": "Object",
"required": false,
"index": {
"kind": "2dsphere"
}
}
};
```

and this will execute

```
db[collection].ensureIndex({"geometry":"2dsphere"});
```

I used the "kind" attribute to be consistent with loopback-mysql-connector. Besides 2dsphere indexes, you can also create [2d](http://docs.mongodb.org/manual/core/2d/), [text](http://docs.mongodb.org/manual/core/index-text/) and [geoHaystack](http://docs.mongodb.org/manual/core/geohaystack/) indexes.