Add db indexes

Refactor db connection into a collection definition to specify serialization and define indexes.