Revert query to db