You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I got the following usecase:
I got books and Shelfs, Books can be assigned to Shelfs.
There is the case a book isnt assigned to a shelf and there for the shelf_id should be nil
I tried the Nullable command on a Field, but does not work.
type Book struct {
ID int `gorm:"primary_key"` // primary key
ShelfID int // has many Book
}
type Shelf struct {
ID int `gorm:"primary_key"` // primary key
Books []Book // has many Books
}
But what i actualy want is (note the pointer to *int)
type Book struct {
ID int `gorm:"primary_key"` // primary key
ShelfID *int // has many Book
}
How can i achieve this? or is this even possible.
The text was updated successfully, but these errors were encountered:
I got the following usecase:
I got books and Shelfs, Books can be assigned to Shelfs.
There is the case a book isnt assigned to a shelf and there for the shelf_id should be nil
I tried the Nullable command on a Field, but does not work.
This will generate a model like:
But what i actualy want is (note the pointer to *int)
How can i achieve this? or is this even possible.
The text was updated successfully, but these errors were encountered: