Quarry Docs
GitHub
Example

Scan One Row

Use scan.One when the query should return exactly one row. The contract stays explicit: empty results error, ambiguous results error, and the row shape stays obvious.

Quarry logo

The shape

type UserRow struct {
    ID     int    `db:"id"`
    Email  string `db:"email"`
    Status string `db:"status"`
}

This is the simplest path through the scan package. A single struct, a single query, and a single row-count expectation.

Run it

user, err := scan.One[UserRow](ctx, db,
    qq.Select("id", "email", "status").
        From("users").
        Where(quarry.Eq("id", 1)),
)
Why this is strict scan.One keeps the row-count contract explicit instead of silently picking the first row when the result set is wrong.

What the output looks like

{1 a@example.com active}