I´m writing a small web service in Go which uses Postgres through the pq driver package.
I´m using a uuid´s as identifier for my models so LastInsertId won´t work.
So I´m thinking I could something like this:
var id string
res, err := session.Exec("INSERT INTO todos (text, list_id) VALUES ($1, $2) RETURNING todo_id", text, listId).Scan(&id)
Scan
does seem to play well with Exec
.
So how do I return the uuid from my new todo row?