product.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package db
  2. import (
  3. "github.com/gshopify/service-wrapper/model"
  4. "gshopper.com/gshopify/products/cache"
  5. "time"
  6. )
  7. var (
  8. productKey = func(clause string, args ...any) *cache.SqlKey {
  9. return cache.NewSQLKey(
  10. "product",
  11. time.Minute,
  12. clause, args...)
  13. }
  14. productSelection = func(ln model.LanguageCode) []string {
  15. return append([]string{
  16. "id", "profile_id", "collection_ids", "type_id", "handle", "thumbnail", "is_giftcard", "discountable",
  17. "hs_code", "mid_code", "weight", "length", "height", "width", "origin_country", "vendor", "material",
  18. "created_at", "updated_at", "deleted_at", "tags", "status",
  19. },
  20. ln.SqlFieldSelection("title"),
  21. ln.SqlFieldSelection("subtitle"),
  22. ln.SqlFieldSelection("description"),
  23. )
  24. }
  25. productCollectionKey = func(clause string, args ...any) *cache.SqlKey {
  26. return cache.NewSQLKey(
  27. "product_collection",
  28. 3*time.Minute,
  29. clause,
  30. args...,
  31. )
  32. }
  33. productOptionSelection = func(ln model.LanguageCode) []string {
  34. return append([]string{
  35. "id", "product_id",
  36. "created_at", "updated_at", "deleted_at",
  37. },
  38. ln.SqlFieldSelection("name"),
  39. ln.SqlArraySelection("values"),
  40. )
  41. }
  42. productOptionKey = func(clause string, args ...any) *cache.SqlKey {
  43. return cache.NewSQLKey(
  44. "product_option",
  45. time.Second*30,
  46. clause, args...)
  47. }
  48. )