Skip to content

Instantly share code, notes, and snippets.

@Solution
Created May 13, 2021 13:26
Show Gist options
  • Save Solution/6c61bac652175cdc3ae233388c6eab9b to your computer and use it in GitHub Desktop.
Save Solution/6c61bac652175cdc3ae233388c6eab9b to your computer and use it in GitHub Desktop.
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