Turn db query function into a class method.