Created
August 20, 2023 11:50
-
-
Save masahiko-nitanda/01a03a1cf72be94c228273b83f995497 to your computer and use it in GitHub Desktop.
This Gist is a Go code snippet using GORM to query for a user with a specific name (in this case, "Alice"). The User struct embeds gorm.Model, allowing for automatic management of created_at, updated_at, and deleted_at fields in CRUD operations.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type User struct { | |
gorm.Model | |
Name string | |
} | |
db.Model(&User{}).Where("name = ?", "Alice").First(&user) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment