rov66
rov66

Reputation: 53

LokiJS: How to create index (or UniqueIndex) on nested document properties

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?

Upvotes: 5

Views: 488

Answers (1)

Joe Minichino
Joe Minichino

Reputation: 2773

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.

Upvotes: 3

Related Questions