You've already forked gun-manager-backend
37 lines
1.0 KiB
SQL
37 lines
1.0 KiB
SQL
-- name: GetGunById :one
|
|
SELECT guns.id as id, make, model, serial_number, purchase_amount, value_amount, date_purchased, notes
|
|
from guns
|
|
where guns.id = ?;
|
|
|
|
-- name: GetGunPhotos :many
|
|
SELECT id, filename from photos where gun_id = ?;
|
|
|
|
-- name: GetGunPhotoData :one
|
|
select photo from photos where id = ?;
|
|
|
|
-- name: GetAllGuns :many
|
|
SELECT id, make, model, value_amount
|
|
from guns
|
|
order by id desc;
|
|
|
|
-- name: InsertGun :one
|
|
INSERT into guns
|
|
(make, model, serial_number, purchase_amount, value_amount, date_purchased, notes) VALUES
|
|
(?, ?, ?, ?, ?, ?, ?) returning id;
|
|
|
|
-- name: UpdateGun :exec
|
|
UPDATE guns
|
|
set make = ?, model = ?, serial_number = ?, purchase_amount = ?, value_amount = ?, date_purchased = ?, notes = ?
|
|
where id = ?;
|
|
|
|
-- name: DeleteGun :exec
|
|
DELETE from guns where id = ?;
|
|
|
|
-- name: DeleteGunPhotosByGunId :exec
|
|
DELETE FROM photos where gun_id = ?;
|
|
|
|
-- name: DeleteGunPhotosById :exec
|
|
DELETE FROM photos where id = ?;
|
|
|
|
-- name: InsertGunPhoto :exec
|
|
INSERT into photos (gun_id, photo, filename) values (?, ?, ?); |