models.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Code generated by sqlc. DO NOT EDIT.
  2. // versions:
  3. // sqlc v1.27.0
  4. package booktest
  5. import (
  6. "database/sql/driver"
  7. "fmt"
  8. "time"
  9. )
  10. type BooksBookType string
  11. const (
  12. BooksBookTypeFICTION BooksBookType = "FICTION"
  13. BooksBookTypeNONFICTION BooksBookType = "NONFICTION"
  14. )
  15. func (e *BooksBookType) Scan(src interface{}) error {
  16. switch s := src.(type) {
  17. case []byte:
  18. *e = BooksBookType(s)
  19. case string:
  20. *e = BooksBookType(s)
  21. default:
  22. return fmt.Errorf("unsupported scan type for BooksBookType: %T", src)
  23. }
  24. return nil
  25. }
  26. type NullBooksBookType struct {
  27. BooksBookType BooksBookType
  28. Valid bool // Valid is true if BooksBookType is not NULL
  29. }
  30. // Scan implements the Scanner interface.
  31. func (ns *NullBooksBookType) Scan(value interface{}) error {
  32. if value == nil {
  33. ns.BooksBookType, ns.Valid = "", false
  34. return nil
  35. }
  36. ns.Valid = true
  37. return ns.BooksBookType.Scan(value)
  38. }
  39. // Value implements the driver Valuer interface.
  40. func (ns NullBooksBookType) Value() (driver.Value, error) {
  41. if !ns.Valid {
  42. return nil, nil
  43. }
  44. return string(ns.BooksBookType), nil
  45. }
  46. type Author struct {
  47. AuthorID int32
  48. Name string
  49. }
  50. type Book struct {
  51. BookID int32
  52. AuthorID int32
  53. Isbn string
  54. BookType BooksBookType
  55. Title string
  56. Yr int32
  57. Available time.Time
  58. Tags string
  59. }