Skip to content

Instantly share code, notes, and snippets.

@shanev
Created January 21, 2019 19:52
Show Gist options
  • Save shanev/785dc8586b1e3a7c6745006cb5f62ef2 to your computer and use it in GitHub Desktop.
Save shanev/785dc8586b1e3a7c6745006cb5f62ef2 to your computer and use it in GitHub Desktop.
// Updates an existing Profile or creates a new one
func (c *Client) UpsertProfile(profile *Profile) error {
_, err := c.Model(profile).
OnConflict("(id) DO UPDATE").
Set("username = EXCLUDED.username").
Insert()
return err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment