To create an index (or UniqueIndex) on a LokiJS collection you just need to specify the field name:
db.addCollection('Children',{indices:['name']})
...will create an index on 'name' property of documents in the collection.
That's ok for simple documents. But what if your doc has nested objects? ie.:
{
propA: 123,
propB: 'abc',
propC: {
propC1: 789,
propC2: 'xyz'
}
}
Is there a way to specify an index on propC1?
sorry to burst the bubble but LokiJS only supports top-level properties at the moment for indexes.
This issue has been coming up a few times recently so it's possible it will make it in the roadmap but it is definitely not supported at the moment.