-
Notifications
You must be signed in to change notification settings - Fork 372
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 support #254
Comments
You can implement |
@fbjork does nelsam's reply answer your question? |
TL;DR:
The documentation and tests presents different possible approaches to achieve this:
In the first example, the However:
Postgres JSON features are getting better and more popular with each release, from 9.3 to the latest 9.5. In addition to being able to return a traditional dataset as a JSON representation using @jmoiron 's "sqlx" features a As a conclusion, a possible approach could be:
|
Was just working through the same issue - didn't find any more recent info than this thread unfortunately. Really good ideas here but I just hated that I was required to go back and alter the table to set the column type to jsonb. My solution was to use embedding to extend gorp.PostgresDialect as follows:
Very clean and I brought the JSONText struct over from @jmoiron 's "sqlx". Haven't fully tested with that struct but once I get the other side of this project working, I'll decide if it meets the need or if I need to roll my own. But - I love that this is a minor passthrough that lets
do what it needs to do without any post-creation cleanup. |
I just found this article, Handling JSONB in Go Structs. Hope it is helpful if you are looking for a solution. |
Is it possible to store JSON blobs in Postgres with gorp? Any examples?
The text was updated successfully, but these errors were encountered: