add encode support for db quieries