Utils for a unified way to query the database