Includes relevant unit-test. Branched from jay/current_database (please merge that branch first!).
Preserves the gorm-style query API.