move db query helpers into base with constructor