[WIP] add support for secondary indexes

We should also be able to use _indexAttributes to simplify this.