I'd like to use a unique string per collection to id a doc. I'm using Scala and Casbah but can also use Java if needed.
I know I should use Casbah collection.createIndex
but I don't understand the scaladocs.
If my case class is :
case class GroupParams (
_id: String,
//groupId: String,
testPeriodStart: DateTime, // ISO8601 date
variants: Seq[String], //["17","18"]
testPeriodEnd: Option[DateTime])
and I will always use the _id to reference a particular document (no need for _id: ObjectId
).
I don't care about sorting/ordering since these will only be accessed as individual docs, never cursored through. There seems no reason to have the overhead of another index on the default _id: ObjectId
.
How to I create the index on the collection with _id: String
using Casbah? If I should create a new index and leave the default alone can you show how to do this?