Loggest thy stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.3 KiB

  1. -- name: GetScope :one
  2. SELECT id, name, abbreviation FROM scope
  3. WHERE id = ?;
  4. -- name: ListScopes :many
  5. SELECT id, name, abbreviation FROM scope
  6. ORDER BY name;
  7. -- name: ListScopesByUser :many
  8. SELECT id, s.name, abbreviation, sm.name as display_name FROM scope_member sm
  9. RIGHT JOIN scope s on s.id = sm.scope_id
  10. WHERE sm.user_id = ?
  11. ORDER BY s.name;
  12. -- name: ListScopeMembers :many
  13. SELECT user_id, name, owner FROM scope_member
  14. WHERE scope_id = ?
  15. ORDER BY name;
  16. -- name: GetScopeWithDisplayName :one
  17. SELECT id, scope.name, abbreviation, sm.name AS display_name FROM scope
  18. LEFT JOIN scope_member sm ON scope.id = sm.scope_id
  19. WHERE id = ? AND sm.user_id = ?;
  20. -- name: GetScopeDisplayName :one
  21. SELECT name FROM scope_member
  22. WHERE user_id = ? AND scope_id = ?;
  23. -- name: InsertScope :execresult
  24. INSERT INTO scope (id, name, abbreviation)
  25. VALUES (?, ?, ?);
  26. -- name: UpdateScope :exec
  27. UPDATE scope SET name = ?, abbreviation = ? WHERE id = ?;
  28. -- name: UpdateScopeMember :exec
  29. REPLACE INTO scope_member (scope_id, user_id, name, owner)
  30. VALUES (?, ?, ?, ?);
  31. -- name: DeleteScopeMember :exec
  32. DELETE FROM scope_member WHERE scope_id=? AND user_id=?;
  33. -- name: DeleteAllScopeMembers :exec
  34. DELETE FROM scope_member WHERE scope_id=?;
  35. -- name: DeleteScope :exec
  36. DELETE FROM scope WHERE id=?;