如何使用Firebase的新bolt编译器定义索引

时间:2015-12-10 21:28:31

标签: firebase firebase-security firebase-realtime-database

我正在使用新的螺栓编译器(在此处介绍:https://www.firebase.com/blog/2015-11-09-introducing-the-bolt-compiler.html

我需要在我的类型Event的所有者字段中定义索引:

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

当我尝试编译此代码时,我得到以下输出:

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

请帮助:我应该如何定义索引?我想我需要在路径声明中定义它们吗?

bolt编译器的文档在定义索引方面并不多:https://github.com/firebase/bolt/blob/master/docs/language.md

2 个答案:

答案 0 :(得分:9)

只需found the answer

path /users/$uid/events {
    index() = "owner";
}

答案 1 :(得分:1)

将类型信息与索引相结合:

path /events is Event[] {
  index() = "owner";
}