Move db query from route to controller.