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
How to define []string in Gorm Model #4498
Comments
I also got this error
|
This is the test i wrote (I am very new to Go btw):
The Error gets thrown from by the Create Method
|
Got it to work when I changed the string[] to pq.StringArray |
Is this documented anywhere? Spent a lot of time trying to find this answer. |
Me too, the docs are a bit rotten. It would be better if the error message was accompanied by suggestions, such as 'maybe you need to add |
|
Hi~ @jinzhu, Guess which one of them works?
If they both work, which one is better to use? |
I have been trying to define a []string in a Gorm Model looking like this
My Model struct looks like this:
When I try to AutoMigrate it like this:
db.AutoMigrate(&Shoppinglist{})
I get an error:
And I think its the []string because I can't find it in an example in the documentation. I would highly appreciate any help!
The document you expected this should be explained
I'd expect it to be explained in https://gorm.io/docs/models.html
Expected answer
I want to know if something is wrong with my Model and if, what?
E.g. is it the []string or is it something completly different. And if it is the []string how do I store an Array?
The text was updated successfully, but these errors were encountered: