porter_app_revisions.sql.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Code generated by sqlc. DO NOT EDIT.
  2. // versions:
  3. // sqlc v1.18.0
  4. // source: porter_app_revisions.sql
  5. package queries
  6. import (
  7. "context"
  8. )
  9. const createPorterAppRevision = `-- name: CreatePorterAppRevision :one
  10. INSERT INTO porter_app_revisions
  11. (project_id, base64_contract)
  12. VALUES
  13. ($1, $2) RETURNING id, created_at, updated_at, deleted_at, base64_contract, project_id
  14. `
  15. type CreatePorterAppRevisionParams struct {
  16. ProjectID int64
  17. Base64Contract string
  18. }
  19. func (q *Queries) CreatePorterAppRevision(ctx context.Context, arg CreatePorterAppRevisionParams) (PorterAppRevision, error) {
  20. row := q.db.QueryRowContext(ctx, createPorterAppRevision, arg.ProjectID, arg.Base64Contract)
  21. var i PorterAppRevision
  22. err := row.Scan(
  23. &i.ID,
  24. &i.CreatedAt,
  25. &i.UpdatedAt,
  26. &i.DeletedAt,
  27. &i.Base64Contract,
  28. &i.ProjectID,
  29. )
  30. return i, err
  31. }
  32. const porterAppRevisionsForProject = `-- name: PorterAppRevisionsForProject :many
  33. SELECT id, created_at, updated_at, deleted_at, base64_contract, project_id FROM porter_app_revisions
  34. WHERE project_id = $1 AND deleted_at IS NULL
  35. `
  36. func (q *Queries) PorterAppRevisionsForProject(ctx context.Context, projectID int64) ([]PorterAppRevision, error) {
  37. rows, err := q.db.QueryContext(ctx, porterAppRevisionsForProject, projectID)
  38. if err != nil {
  39. return nil, err
  40. }
  41. defer rows.Close()
  42. var items []PorterAppRevision
  43. for rows.Next() {
  44. var i PorterAppRevision
  45. if err := rows.Scan(
  46. &i.ID,
  47. &i.CreatedAt,
  48. &i.UpdatedAt,
  49. &i.DeletedAt,
  50. &i.Base64Contract,
  51. &i.ProjectID,
  52. ); err != nil {
  53. return nil, err
  54. }
  55. items = append(items, i)
  56. }
  57. if err := rows.Close(); err != nil {
  58. return nil, err
  59. }
  60. if err := rows.Err(); err != nil {
  61. return nil, err
  62. }
  63. return items, nil
  64. }