lib: add support for named queries