WIP: extract database client code from syncstorage