github.com/crowdsecurity/crowdsec@v1.6.1/pkg/database/ent/machine/machine.go (about)

     1  // Code generated by ent, DO NOT EDIT.
     2  
     3  package machine
     4  
     5  import (
     6  	"time"
     7  
     8  	"entgo.io/ent/dialect/sql"
     9  	"entgo.io/ent/dialect/sql/sqlgraph"
    10  )
    11  
    12  const (
    13  	// Label holds the string label denoting the machine type in the database.
    14  	Label = "machine"
    15  	// FieldID holds the string denoting the id field in the database.
    16  	FieldID = "id"
    17  	// FieldCreatedAt holds the string denoting the created_at field in the database.
    18  	FieldCreatedAt = "created_at"
    19  	// FieldUpdatedAt holds the string denoting the updated_at field in the database.
    20  	FieldUpdatedAt = "updated_at"
    21  	// FieldLastPush holds the string denoting the last_push field in the database.
    22  	FieldLastPush = "last_push"
    23  	// FieldLastHeartbeat holds the string denoting the last_heartbeat field in the database.
    24  	FieldLastHeartbeat = "last_heartbeat"
    25  	// FieldMachineId holds the string denoting the machineid field in the database.
    26  	FieldMachineId = "machine_id"
    27  	// FieldPassword holds the string denoting the password field in the database.
    28  	FieldPassword = "password"
    29  	// FieldIpAddress holds the string denoting the ipaddress field in the database.
    30  	FieldIpAddress = "ip_address"
    31  	// FieldScenarios holds the string denoting the scenarios field in the database.
    32  	FieldScenarios = "scenarios"
    33  	// FieldVersion holds the string denoting the version field in the database.
    34  	FieldVersion = "version"
    35  	// FieldIsValidated holds the string denoting the isvalidated field in the database.
    36  	FieldIsValidated = "is_validated"
    37  	// FieldStatus holds the string denoting the status field in the database.
    38  	FieldStatus = "status"
    39  	// FieldAuthType holds the string denoting the auth_type field in the database.
    40  	FieldAuthType = "auth_type"
    41  	// EdgeAlerts holds the string denoting the alerts edge name in mutations.
    42  	EdgeAlerts = "alerts"
    43  	// Table holds the table name of the machine in the database.
    44  	Table = "machines"
    45  	// AlertsTable is the table that holds the alerts relation/edge.
    46  	AlertsTable = "alerts"
    47  	// AlertsInverseTable is the table name for the Alert entity.
    48  	// It exists in this package in order to avoid circular dependency with the "alert" package.
    49  	AlertsInverseTable = "alerts"
    50  	// AlertsColumn is the table column denoting the alerts relation/edge.
    51  	AlertsColumn = "machine_alerts"
    52  )
    53  
    54  // Columns holds all SQL columns for machine fields.
    55  var Columns = []string{
    56  	FieldID,
    57  	FieldCreatedAt,
    58  	FieldUpdatedAt,
    59  	FieldLastPush,
    60  	FieldLastHeartbeat,
    61  	FieldMachineId,
    62  	FieldPassword,
    63  	FieldIpAddress,
    64  	FieldScenarios,
    65  	FieldVersion,
    66  	FieldIsValidated,
    67  	FieldStatus,
    68  	FieldAuthType,
    69  }
    70  
    71  // ValidColumn reports if the column name is valid (part of the table columns).
    72  func ValidColumn(column string) bool {
    73  	for i := range Columns {
    74  		if column == Columns[i] {
    75  			return true
    76  		}
    77  	}
    78  	return false
    79  }
    80  
    81  var (
    82  	// DefaultCreatedAt holds the default value on creation for the "created_at" field.
    83  	DefaultCreatedAt func() time.Time
    84  	// UpdateDefaultCreatedAt holds the default value on update for the "created_at" field.
    85  	UpdateDefaultCreatedAt func() time.Time
    86  	// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
    87  	DefaultUpdatedAt func() time.Time
    88  	// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
    89  	UpdateDefaultUpdatedAt func() time.Time
    90  	// DefaultLastPush holds the default value on creation for the "last_push" field.
    91  	DefaultLastPush func() time.Time
    92  	// UpdateDefaultLastPush holds the default value on update for the "last_push" field.
    93  	UpdateDefaultLastPush func() time.Time
    94  	// DefaultLastHeartbeat holds the default value on creation for the "last_heartbeat" field.
    95  	DefaultLastHeartbeat func() time.Time
    96  	// UpdateDefaultLastHeartbeat holds the default value on update for the "last_heartbeat" field.
    97  	UpdateDefaultLastHeartbeat func() time.Time
    98  	// ScenariosValidator is a validator for the "scenarios" field. It is called by the builders before save.
    99  	ScenariosValidator func(string) error
   100  	// DefaultIsValidated holds the default value on creation for the "isValidated" field.
   101  	DefaultIsValidated bool
   102  	// DefaultAuthType holds the default value on creation for the "auth_type" field.
   103  	DefaultAuthType string
   104  )
   105  
   106  // OrderOption defines the ordering options for the Machine queries.
   107  type OrderOption func(*sql.Selector)
   108  
   109  // ByID orders the results by the id field.
   110  func ByID(opts ...sql.OrderTermOption) OrderOption {
   111  	return sql.OrderByField(FieldID, opts...).ToFunc()
   112  }
   113  
   114  // ByCreatedAt orders the results by the created_at field.
   115  func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
   116  	return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
   117  }
   118  
   119  // ByUpdatedAt orders the results by the updated_at field.
   120  func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
   121  	return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
   122  }
   123  
   124  // ByLastPush orders the results by the last_push field.
   125  func ByLastPush(opts ...sql.OrderTermOption) OrderOption {
   126  	return sql.OrderByField(FieldLastPush, opts...).ToFunc()
   127  }
   128  
   129  // ByLastHeartbeat orders the results by the last_heartbeat field.
   130  func ByLastHeartbeat(opts ...sql.OrderTermOption) OrderOption {
   131  	return sql.OrderByField(FieldLastHeartbeat, opts...).ToFunc()
   132  }
   133  
   134  // ByMachineId orders the results by the machineId field.
   135  func ByMachineId(opts ...sql.OrderTermOption) OrderOption {
   136  	return sql.OrderByField(FieldMachineId, opts...).ToFunc()
   137  }
   138  
   139  // ByPassword orders the results by the password field.
   140  func ByPassword(opts ...sql.OrderTermOption) OrderOption {
   141  	return sql.OrderByField(FieldPassword, opts...).ToFunc()
   142  }
   143  
   144  // ByIpAddress orders the results by the ipAddress field.
   145  func ByIpAddress(opts ...sql.OrderTermOption) OrderOption {
   146  	return sql.OrderByField(FieldIpAddress, opts...).ToFunc()
   147  }
   148  
   149  // ByScenarios orders the results by the scenarios field.
   150  func ByScenarios(opts ...sql.OrderTermOption) OrderOption {
   151  	return sql.OrderByField(FieldScenarios, opts...).ToFunc()
   152  }
   153  
   154  // ByVersion orders the results by the version field.
   155  func ByVersion(opts ...sql.OrderTermOption) OrderOption {
   156  	return sql.OrderByField(FieldVersion, opts...).ToFunc()
   157  }
   158  
   159  // ByIsValidated orders the results by the isValidated field.
   160  func ByIsValidated(opts ...sql.OrderTermOption) OrderOption {
   161  	return sql.OrderByField(FieldIsValidated, opts...).ToFunc()
   162  }
   163  
   164  // ByStatus orders the results by the status field.
   165  func ByStatus(opts ...sql.OrderTermOption) OrderOption {
   166  	return sql.OrderByField(FieldStatus, opts...).ToFunc()
   167  }
   168  
   169  // ByAuthType orders the results by the auth_type field.
   170  func ByAuthType(opts ...sql.OrderTermOption) OrderOption {
   171  	return sql.OrderByField(FieldAuthType, opts...).ToFunc()
   172  }
   173  
   174  // ByAlertsCount orders the results by alerts count.
   175  func ByAlertsCount(opts ...sql.OrderTermOption) OrderOption {
   176  	return func(s *sql.Selector) {
   177  		sqlgraph.OrderByNeighborsCount(s, newAlertsStep(), opts...)
   178  	}
   179  }
   180  
   181  // ByAlerts orders the results by alerts terms.
   182  func ByAlerts(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
   183  	return func(s *sql.Selector) {
   184  		sqlgraph.OrderByNeighborTerms(s, newAlertsStep(), append([]sql.OrderTerm{term}, terms...)...)
   185  	}
   186  }
   187  func newAlertsStep() *sqlgraph.Step {
   188  	return sqlgraph.NewStep(
   189  		sqlgraph.From(Table, FieldID),
   190  		sqlgraph.To(AlertsInverseTable, FieldID),
   191  		sqlgraph.Edge(sqlgraph.O2M, false, AlertsTable, AlertsColumn),
   192  	)
   193  }