Works using to_json

This is probably not the right way to do it, in fact, I'm sure
it is not -- this will fail for very big objects. Better here
is to stream the response from postgres, probably using an asynchronous
postgres driver. Also it's not clear whether to_json is efficient on the
postgres side. If it is, then we can make this service efficient; if it
is not, then we need to figure out how to progressively render json from
a streaming response from the database.