Files
go-http-server/internal/database/CreateChirp.sql.go
2025-03-11 19:08:34 +02:00

37 lines
725 B
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// source: CreateChirp.sql
package database
import (
"context"
"github.com/google/uuid"
)
const createChirp = `-- name: CreateChirp :one
INSERT INTO chirps (id, created_at, updated_at, body, user_id)
VALUES (gen_random_uuid(), NOW(), NOW(), $1, $2)
RETURNING id, created_at, updated_at, body, user_id
`
type CreateChirpParams struct {
Body string
UserID uuid.UUID
}
func (q *Queries) CreateChirp(ctx context.Context, arg CreateChirpParams) (Chirp, error) {
row := q.db.QueryRowContext(ctx, createChirp, arg.Body, arg.UserID)
var i Chirp
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.Body,
&i.UserID,
)
return i, err
}