user.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. // Code generated by entc, DO NOT EDIT.
  2. package user
  3. import (
  4. "fmt"
  5. )
  6. const (
  7. // Label holds the string label denoting the user type in the database.
  8. Label = "user"
  9. // FieldID holds the string denoting the id field in the database.
  10. FieldID = "id"
  11. // FieldAge holds the string denoting the age field in the database.
  12. FieldAge = "age"
  13. // FieldName holds the string denoting the name field in the database.
  14. FieldName = "name"
  15. // FieldPassword holds the string denoting the password field in the database.
  16. FieldPassword = "password"
  17. // FieldSize holds the string denoting the size field in the database.
  18. FieldSize = "size"
  19. // FieldSpouseID holds the string denoting the spouse_id field in the database.
  20. FieldSpouseID = "spouse_id"
  21. // EdgeCars holds the string denoting the cars edge name in mutations.
  22. EdgeCars = "cars"
  23. // EdgeGroups holds the string denoting the groups edge name in mutations.
  24. EdgeGroups = "groups"
  25. // EdgeSpouse holds the string denoting the spouse edge name in mutations.
  26. EdgeSpouse = "spouse"
  27. // EdgeFollowers holds the string denoting the followers edge name in mutations.
  28. EdgeFollowers = "followers"
  29. // EdgeFollowing holds the string denoting the following edge name in mutations.
  30. EdgeFollowing = "following"
  31. // EdgeFriends holds the string denoting the friends edge name in mutations.
  32. EdgeFriends = "friends"
  33. // Table holds the table name of the user in the database.
  34. Table = "users"
  35. // CarsTable is the table that holds the cars relation/edge.
  36. CarsTable = "cars"
  37. // CarsInverseTable is the table name for the Car entity.
  38. // It exists in this package in order to avoid circular dependency with the "car" package.
  39. CarsInverseTable = "cars"
  40. // CarsColumn is the table column denoting the cars relation/edge.
  41. CarsColumn = "user_cars"
  42. // GroupsTable is the table that holds the groups relation/edge. The primary key declared below.
  43. GroupsTable = "group_users"
  44. // GroupsInverseTable is the table name for the Group entity.
  45. // It exists in this package in order to avoid circular dependency with the "group" package.
  46. GroupsInverseTable = "groups"
  47. // SpouseTable is the table that holds the spouse relation/edge.
  48. SpouseTable = "users"
  49. // SpouseColumn is the table column denoting the spouse relation/edge.
  50. SpouseColumn = "spouse_id"
  51. // FollowersTable is the table that holds the followers relation/edge. The primary key declared below.
  52. FollowersTable = "user_following"
  53. // FollowingTable is the table that holds the following relation/edge. The primary key declared below.
  54. FollowingTable = "user_following"
  55. // FriendsTable is the table that holds the friends relation/edge. The primary key declared below.
  56. FriendsTable = "user_friends"
  57. )
  58. // Columns holds all SQL columns for user fields.
  59. var Columns = []string{
  60. FieldID,
  61. FieldAge,
  62. FieldName,
  63. FieldPassword,
  64. FieldSize,
  65. FieldSpouseID,
  66. }
  67. var (
  68. // GroupsPrimaryKey and GroupsColumn2 are the table columns denoting the
  69. // primary key for the groups relation (M2M).
  70. GroupsPrimaryKey = []string{"group_id", "user_id"}
  71. // FollowersPrimaryKey and FollowersColumn2 are the table columns denoting the
  72. // primary key for the followers relation (M2M).
  73. FollowersPrimaryKey = []string{"user_id", "follower_id"}
  74. // FollowingPrimaryKey and FollowingColumn2 are the table columns denoting the
  75. // primary key for the following relation (M2M).
  76. FollowingPrimaryKey = []string{"user_id", "follower_id"}
  77. // FriendsPrimaryKey and FriendsColumn2 are the table columns denoting the
  78. // primary key for the friends relation (M2M).
  79. FriendsPrimaryKey = []string{"user_id", "friend_id"}
  80. )
  81. // ValidColumn reports if the column name is valid (part of the table columns).
  82. func ValidColumn(column string) bool {
  83. for i := range Columns {
  84. if column == Columns[i] {
  85. return true
  86. }
  87. }
  88. return false
  89. }
  90. var (
  91. // AgeValidator is a validator for the "age" field. It is called by the builders before save.
  92. AgeValidator func(int) error
  93. // DefaultName holds the default value on creation for the "name" field.
  94. DefaultName string
  95. )
  96. // Size defines the type for the "size" enum field.
  97. type Size string
  98. // SizeM is the default value of the Size enum.
  99. const DefaultSize = SizeM
  100. // Size values.
  101. const (
  102. SizeXS Size = "XS"
  103. SizeS Size = "S"
  104. SizeM Size = "M"
  105. SizeL Size = "L"
  106. SizeXL Size = "XL"
  107. )
  108. func (s Size) String() string {
  109. return string(s)
  110. }
  111. // SizeValidator is a validator for the "size" field enum values. It is called by the builders before save.
  112. func SizeValidator(s Size) error {
  113. switch s {
  114. case SizeXS, SizeS, SizeM, SizeL, SizeXL:
  115. return nil
  116. default:
  117. return fmt.Errorf("user: invalid enum value for size field: %q", s)
  118. }
  119. }