9 type appRepository struct {
13 func NewAppRepository(db *sql.DB) (*appRepository, error) {
14 _, err := db.Exec(`CREATE TABLE IF NOT EXISTS app
15 (instance_url varchar, client_id varchar, client_secret varchar)`,
21 return &appRepository{
26 func (repo *appRepository) Add(a model.App) (err error) {
27 _, err = repo.db.Exec("INSERT INTO app VALUES (?, ?, ?)", a.InstanceURL, a.ClientID, a.ClientSecret)
31 func (repo *appRepository) Update(instanceURL string, clientID string, clientSecret string) (err error) {
32 _, err = repo.db.Exec("UPDATE app SET client_id = ?, client_secret = ? where instance_url = ?", clientID, clientSecret, instanceURL)
36 func (repo *appRepository) Get(instanceURL string) (a model.App, err error) {
37 rows, err := repo.db.Query("SELECT * FROM app WHERE instance_url = ?", instanceURL)
44 err = model.ErrAppNotFound
48 err = rows.Scan(&a.InstanceURL, &a.ClientID, &a.ClientSecret)