예제 #1
0
func (gud *GoogleUserDelegate) ResolveUniqueID(db ab.DB, entity ab.Entity) (string, error) {
	if user, ok := entity.(*User); ok {
		var uuid string
		err := db.QueryRow(`SELECT uuid FROM "user" WHERE mail = $1`, user.Mail).Scan(&uuid)
		if err != nil {
			return "", err
		}
		return uuid, nil
	}
	return "", nil
}
예제 #2
0
func (e *Walkthrough) Insert(db ab.DB) error {
	if e.UUID == "" {
		e.UUID = uuid.NewRandom().String()
	}

	jsonSteps := ""

	bjsonSteps, _ := json.Marshal(e.Steps)
	jsonSteps = string(bjsonSteps)
	return db.QueryRow("INSERT INTO \"walkthrough\"(uuid, uid, name, description, steps, updated, published) VALUES($1, $2, $3, $4, $5, $6, $7) RETURNING revision", e.UUID, e.UID, e.Name, e.Description, jsonSteps, e.Updated, e.Published).Scan(&e.Revision)
}
예제 #3
0
func (sis *SiteinfoService) getFromDB(db ab.DB, site string) (siteInfoResponse, error) {
	resp := siteInfoResponse{}

	if err := db.QueryRow("SELECT blocks_iframe, has_embed_code FROM siteinfo WHERE url = $1 AND created > (now() - '1 month'::interval)", site).Scan(&resp.BlocksIframe, &resp.HasEmbedCode); err != nil {
		if err == sql.ErrNoRows {
			return resp, nil
		}
		return siteInfoResponse{}, err
	}

	resp.Url = site

	return resp, nil
}