Extract db access into repository abstraction