Created
January 21, 2019 19:44
-
-
Save shanev/c6d742f63e639aa722db95f1dd658974 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// GenericQueries are generic reads for models | |
type GenericQueries interface { | |
Count(model interface{}) (int, error) | |
Find(model interface{}) error | |
FindAll(models interface{}) error | |
} | |
// Count returns the count of the model | |
func (c *Client) Count(model interface{}) (count int, err error) { | |
count, err = c.Model(model).Count() | |
return | |
} | |
// Find selects a single model by primary key | |
func (c *Client) Find(model interface{}) error { | |
return c.Select(model) | |
} | |
// FindAll selects all models | |
func (c *Client) FindAll(models interface{}) error { | |
return c.Model(models).Select() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment