WIP rewriting api for postgres