Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgres JSON API #65

Open
vjpr opened this issue Feb 7, 2014 · 0 comments
Open

Postgres JSON API #65

vjpr opened this issue Feb 7, 2014 · 0 comments

Comments

@vjpr
Copy link

vjpr commented Feb 7, 2014

I've started using Postgre's new json features and they are really great.

It allows quick migration-less development, but with the flexibility of indexing individual json properties when neccessary, and eventually splitting them out into columns for joins when needed.

It would be great if Gesundheit had an api to make working with json data really simple. I think the API design would allow this relatively easily with really nice syntax.

For a query like this:

SELECT * FROM "things" WHERE data->>'url'= 'https://xxx'

Currently I write it like this:

    q = g.select @tableName, ->
      @where g.text "data->>'url'= $url", {url}

It would be nice to write it like this

select @tableName, ->
  @where @json('data.url').eql(url)

There are a bunch of other methods too found here: http://www.postgresql.org/docs/9.3/static/functions-json.html

I'd appreciate some guidance on the best way to implement this stuff.


At the moment I'm looking at subclassing Column.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant