Move DB operations to model level