Move db operations to a service