19 lines
348 B
SQL
19 lines
348 B
SQL
-- name: CreateNote :one
|
|
INSERT INTO notes (user_id)
|
|
VALUES ($1)
|
|
RETURNING *;
|
|
|
|
-- name: GetNote :one
|
|
SELECT * FROM notes
|
|
WHERE id = $1 AND user_id = $2 LIMIT 1;
|
|
|
|
-- name: ListNotes :many
|
|
SELECT * FROM notes
|
|
WHERE user_id = $1
|
|
ORDER BY created_at DESC
|
|
LIMIT $2 OFFSET $3;
|
|
|
|
-- name: DeleteNote :exec
|
|
DELETE FROM notes
|
|
WHERE id = $1 AND user_id = $2;
|