channelmonitorhistory.go 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // Code generated by ent, DO NOT EDIT.
  2. package channelmonitorhistory
  3. import (
  4. "fmt"
  5. "time"
  6. "entgo.io/ent/dialect/sql"
  7. "entgo.io/ent/dialect/sql/sqlgraph"
  8. )
  9. const (
  10. // Label holds the string label denoting the channelmonitorhistory type in the database.
  11. Label = "channel_monitor_history"
  12. // FieldID holds the string denoting the id field in the database.
  13. FieldID = "id"
  14. // FieldMonitorID holds the string denoting the monitor_id field in the database.
  15. FieldMonitorID = "monitor_id"
  16. // FieldModel holds the string denoting the model field in the database.
  17. FieldModel = "model"
  18. // FieldStatus holds the string denoting the status field in the database.
  19. FieldStatus = "status"
  20. // FieldLatencyMs holds the string denoting the latency_ms field in the database.
  21. FieldLatencyMs = "latency_ms"
  22. // FieldPingLatencyMs holds the string denoting the ping_latency_ms field in the database.
  23. FieldPingLatencyMs = "ping_latency_ms"
  24. // FieldMessage holds the string denoting the message field in the database.
  25. FieldMessage = "message"
  26. // FieldQuota holds the string denoting the quota field in the database.
  27. FieldQuota = "quota"
  28. // FieldCheckedAt holds the string denoting the checked_at field in the database.
  29. FieldCheckedAt = "checked_at"
  30. // EdgeMonitor holds the string denoting the monitor edge name in mutations.
  31. EdgeMonitor = "monitor"
  32. // Table holds the table name of the channelmonitorhistory in the database.
  33. Table = "channel_monitor_histories"
  34. // MonitorTable is the table that holds the monitor relation/edge.
  35. MonitorTable = "channel_monitor_histories"
  36. // MonitorInverseTable is the table name for the ChannelMonitor entity.
  37. // It exists in this package in order to avoid circular dependency with the "channelmonitor" package.
  38. MonitorInverseTable = "channel_monitors"
  39. // MonitorColumn is the table column denoting the monitor relation/edge.
  40. MonitorColumn = "monitor_id"
  41. )
  42. // Columns holds all SQL columns for channelmonitorhistory fields.
  43. var Columns = []string{
  44. FieldID,
  45. FieldMonitorID,
  46. FieldModel,
  47. FieldStatus,
  48. FieldLatencyMs,
  49. FieldPingLatencyMs,
  50. FieldMessage,
  51. FieldQuota,
  52. FieldCheckedAt,
  53. }
  54. // ValidColumn reports if the column name is valid (part of the table columns).
  55. func ValidColumn(column string) bool {
  56. for i := range Columns {
  57. if column == Columns[i] {
  58. return true
  59. }
  60. }
  61. return false
  62. }
  63. var (
  64. // ModelValidator is a validator for the "model" field. It is called by the builders before save.
  65. ModelValidator func(string) error
  66. // DefaultMessage holds the default value on creation for the "message" field.
  67. DefaultMessage string
  68. // MessageValidator is a validator for the "message" field. It is called by the builders before save.
  69. MessageValidator func(string) error
  70. // DefaultCheckedAt holds the default value on creation for the "checked_at" field.
  71. DefaultCheckedAt func() time.Time
  72. )
  73. // Status defines the type for the "status" enum field.
  74. type Status string
  75. // Status values.
  76. const (
  77. StatusOperational Status = "operational"
  78. StatusDegraded Status = "degraded"
  79. StatusFailed Status = "failed"
  80. StatusError Status = "error"
  81. )
  82. func (s Status) String() string {
  83. return string(s)
  84. }
  85. // StatusValidator is a validator for the "status" field enum values. It is called by the builders before save.
  86. func StatusValidator(s Status) error {
  87. switch s {
  88. case StatusOperational, StatusDegraded, StatusFailed, StatusError:
  89. return nil
  90. default:
  91. return fmt.Errorf("channelmonitorhistory: invalid enum value for status field: %q", s)
  92. }
  93. }
  94. // OrderOption defines the ordering options for the ChannelMonitorHistory queries.
  95. type OrderOption func(*sql.Selector)
  96. // ByID orders the results by the id field.
  97. func ByID(opts ...sql.OrderTermOption) OrderOption {
  98. return sql.OrderByField(FieldID, opts...).ToFunc()
  99. }
  100. // ByMonitorID orders the results by the monitor_id field.
  101. func ByMonitorID(opts ...sql.OrderTermOption) OrderOption {
  102. return sql.OrderByField(FieldMonitorID, opts...).ToFunc()
  103. }
  104. // ByModel orders the results by the model field.
  105. func ByModel(opts ...sql.OrderTermOption) OrderOption {
  106. return sql.OrderByField(FieldModel, opts...).ToFunc()
  107. }
  108. // ByStatus orders the results by the status field.
  109. func ByStatus(opts ...sql.OrderTermOption) OrderOption {
  110. return sql.OrderByField(FieldStatus, opts...).ToFunc()
  111. }
  112. // ByLatencyMs orders the results by the latency_ms field.
  113. func ByLatencyMs(opts ...sql.OrderTermOption) OrderOption {
  114. return sql.OrderByField(FieldLatencyMs, opts...).ToFunc()
  115. }
  116. // ByPingLatencyMs orders the results by the ping_latency_ms field.
  117. func ByPingLatencyMs(opts ...sql.OrderTermOption) OrderOption {
  118. return sql.OrderByField(FieldPingLatencyMs, opts...).ToFunc()
  119. }
  120. // ByMessage orders the results by the message field.
  121. func ByMessage(opts ...sql.OrderTermOption) OrderOption {
  122. return sql.OrderByField(FieldMessage, opts...).ToFunc()
  123. }
  124. // ByCheckedAt orders the results by the checked_at field.
  125. func ByCheckedAt(opts ...sql.OrderTermOption) OrderOption {
  126. return sql.OrderByField(FieldCheckedAt, opts...).ToFunc()
  127. }
  128. // ByMonitorField orders the results by monitor field.
  129. func ByMonitorField(field string, opts ...sql.OrderTermOption) OrderOption {
  130. return func(s *sql.Selector) {
  131. sqlgraph.OrderByNeighborTerms(s, newMonitorStep(), sql.OrderByField(field, opts...))
  132. }
  133. }
  134. func newMonitorStep() *sqlgraph.Step {
  135. return sqlgraph.NewStep(
  136. sqlgraph.From(Table, FieldID),
  137. sqlgraph.To(MonitorInverseTable, FieldID),
  138. sqlgraph.Edge(sqlgraph.M2O, true, MonitorTable, MonitorColumn),
  139. )
  140. }