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

[question] denormalized data via jsonb #36

Open
toddself opened this issue Nov 16, 2017 · 2 comments
Open

[question] denormalized data via jsonb #36

toddself opened this issue Nov 16, 2017 · 2 comments

Comments

@toddself
Copy link

Is there any ability to use this with the jsonb column type and be able to filter based on data available within the object stored there?

We are making heavy use of partially normalized data (with joi as our validation schema for for the denormalized blobs) and it seems like it would be an interesting fit for this.

I’d be happy to investigate a PR if this is of interest or possibly in scope.

@chrisdickinson
Copy link
Owner

chrisdickinson commented Dec 6, 2017

Yes! This should totally be possible & I'd totally love a PR if you have the time. Maybe something like:

Model.object.filter({
  'json_column > field1 > field2:gt': 3, // equiv to json_column #> {field1, field2}
  'json_column >> field1 >> field2:lt': 2 // equiv to json_column #>> {field1, field2}
})

// or, we could treat the json column as a psuedo-joinable table, which would make
// normalizing json columns in client code easier down the line?
Model.object.filter({
  'json_column.field1.field2:gt': 3, // equiv to json_column #> {field1, field2}
  'json_column.field1.field2:lt': 2 // equiv to json_column #>> {field1, field2}
})

@toddself
Copy link
Author

sorry for the very long reply here -- i've been working through some ideas here but haven't had much time to commit any code around it.

my initial stabs at it were more on the second example you've got there, but i'm going to keep plugging away at this.

thanks for the tips!

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

2 participants