func GetUsers(db *pg.DB) ([]*User, error) { var users Users _, err := db.Query(&users, `SELECT * FROM users`) if err != nil { return nil, err } return users, nil }
func GetArticles(db *pg.DB, f *ArticleFilter) ([]*Article, error) { var articles Articles _, err := db.Query(&articles, ` SELECT * FROM articles WHERE 1=1 ?FilterName ?FilterCategory `, f) if err != nil { return nil, err } return articles, nil }
func CreateUser(db *pg.DB, user *User) error { _, err := db.ExecOne(`INSERT INTO users VALUES (?name, ?emails)`, user) return err }
func CreateArticle(db *pg.DB, article *Article) error { _, err := db.ExecOne(`INSERT INTO articles VALUES (?name, ?category_id)`, article) return err }