Files
ent/entc/integration/migrate/entv1/user/user.go
Ariel Mashraki caf721df47 entc/gen: add eager-loading support (#263)
* entc/gen: add OwnFK indicator for type edges

* entc/gen: add Edges field for generated types

* entc/gen: add With<T> method to query-builder template

* entc/gen: scan and assign foreign-keys on eager-loading

* entc/gen: load fk-relations (wip)

* entc/integration: add o2m/m2o tests for eager-loading

* entc/gen: add m2m support for eager-loading

* entc/gen: add integration tests for m2m and subgraphs

* entc/gen/integration: add tests for o2o eager-loading

* all: generate all assets
2020-01-13 17:21:26 +02:00

107 lines
3.4 KiB
Go

// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
// This source code is licensed under the Apache 2.0 license found
// in the LICENSE file in the root directory of this source tree.
// Code generated by entc, DO NOT EDIT.
package user
import (
"fmt"
"github.com/facebookincubator/ent/entc/integration/migrate/entv1/schema"
)
const (
// Label holds the string label denoting the user type in the database.
Label = "user"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldAge holds the string denoting the age vertex property in the database.
FieldAge = "age"
// FieldName holds the string denoting the name vertex property in the database.
FieldName = "name"
// FieldNickname holds the string denoting the nickname vertex property in the database.
FieldNickname = "nickname"
// FieldAddress holds the string denoting the address vertex property in the database.
FieldAddress = "address"
// FieldRenamed holds the string denoting the renamed vertex property in the database.
FieldRenamed = "renamed"
// FieldBlob holds the string denoting the blob vertex property in the database.
FieldBlob = "blob"
// FieldState holds the string denoting the state vertex property in the database.
FieldState = "state"
// Table holds the table name of the user in the database.
Table = "users"
// ParentTable is the table the holds the parent relation/edge.
ParentTable = "users"
// ParentColumn is the table column denoting the parent relation/edge.
ParentColumn = "parent_id"
// ChildrenTable is the table the holds the children relation/edge.
ChildrenTable = "users"
// ChildrenColumn is the table column denoting the children relation/edge.
ChildrenColumn = "parent_id"
// SpouseTable is the table the holds the spouse relation/edge.
SpouseTable = "users"
// SpouseColumn is the table column denoting the spouse relation/edge.
SpouseColumn = "user_spouse_id"
// CarTable is the table the holds the car relation/edge.
CarTable = "cars"
// CarInverseTable is the table name for the Car entity.
// It exists in this package in order to avoid circular dependency with the "car" package.
CarInverseTable = "cars"
// CarColumn is the table column denoting the car relation/edge.
CarColumn = "owner_id"
)
// Columns holds all SQL columns for user fields.
var Columns = []string{
FieldID,
FieldAge,
FieldName,
FieldNickname,
FieldAddress,
FieldRenamed,
FieldBlob,
FieldState,
}
// ForeignKeys holds the SQL foreign-keys that are owned by the User type.
var ForeignKeys = []string{
"parent_id",
"user_spouse_id",
}
var (
fields = schema.User{}.Fields()
// descName is the schema descriptor for name field.
descName = fields[1].Descriptor()
// NameValidator is a validator for the "name" field. It is called by the builders before save.
NameValidator = descName.Validators[0].(func(string) error)
)
// State defines the type for the state enum field.
type State string
// State values.
const (
StateLoggedIn State = "logged_in"
StateLoggedOut State = "logged_out"
)
func (s State) String() string {
return string(s)
}
// StateValidator is a validator for the "state" field enum values. It is called by the builders before save.
func StateValidator(state State) error {
switch state {
case StateLoggedIn, StateLoggedOut:
return nil
default:
return fmt.Errorf("user: invalid enum value for state field: %q", state)
}
}