refactor db for backends, add resty.postgres support