5

I'm using the new bolt compiler (introduced here: https://www.firebase.com/blog/2015-11-09-introducing-the-bolt-compiler.html)

I have the need to define an index on the owner field of my type Event:

type Event {
    description : String | Null,
    name : String,
    color : Number,
    owner : String,
    shared : Boolean
    index() = "owner";
}

When I try to compile this code, I get the following output:

bolt: Generating rules.json...
bolt:1:1: Unsupported method name in type statement: 'index' (allowed: 'validate', 'read', 'write')

Please help: how should I define indexes? I guess I need to define them within a path statement?

The documentation for the bolt compiler does not contain much on defining indexes yet: https://github.com/firebase/bolt/blob/master/docs/language.md

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Peter
  • 10,910
  • 3
  • 35
  • 68

2 Answers2

9

Just found the answer:

path /users/$uid/events {
    index() = "owner";
}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Peter
  • 10,910
  • 3
  • 35
  • 68
1

Combining the type info with the index:

path /events is Event[] {
  index() = "owner";
}
mckoss
  • 6,764
  • 6
  • 33
  • 31