creating chirps!
This commit is contained in:
36
internal/database/CreateChirp.sql.go
Normal file
36
internal/database/CreateChirp.sql.go
Normal file
@@ -0,0 +1,36 @@
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user