Created
May 13, 2021 13:26
-
-
Save Solution/6c61bac652175cdc3ae233388c6eab9b to your computer and use it in GitHub Desktop.
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
func main() { | |
// init the repository based on gorm instance | |
repository := NewRepository(database) | |
// create qo from repository, you can do it again and again | |
qo := repository.NewQueryObject(). | |
FilterByUsername("myUsername"). // compose your q. | |
FilterByActive() | |
// and than fetch it | |
// you can fetch single one.. | |
user, err := repository.FindOne(qo) | |
// or all | |
users, err := repository.FindAll(qo) | |
// or just count but with the same q. | |
usersCount, err := repository.Count(qo) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment