// Code generated by ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "log" "reflect" "gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/migrate" "github.com/google/uuid" "entgo.io/ent" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/categorie" "gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/champpersonnalise" "gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/emplacement" "gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/lienobjetemplacement" "gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet" "gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/piecejointe" ) // Client is the client that holds all ent builders. type Client struct { config // Schema is the client for creating, migrating and dropping schema. Schema *migrate.Schema // Categorie is the client for interacting with the Categorie builders. Categorie *CategorieClient // ChampPersonnalise is the client for interacting with the ChampPersonnalise builders. ChampPersonnalise *ChampPersonnaliseClient // Emplacement is the client for interacting with the Emplacement builders. Emplacement *EmplacementClient // LienObjetEmplacement is the client for interacting with the LienObjetEmplacement builders. LienObjetEmplacement *LienObjetEmplacementClient // Objet is the client for interacting with the Objet builders. Objet *ObjetClient // PieceJointe is the client for interacting with the PieceJointe builders. PieceJointe *PieceJointeClient } // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { client := &Client{config: newConfig(opts...)} client.init() return client } func (c *Client) init() { c.Schema = migrate.NewSchema(c.driver) c.Categorie = NewCategorieClient(c.config) c.ChampPersonnalise = NewChampPersonnaliseClient(c.config) c.Emplacement = NewEmplacementClient(c.config) c.LienObjetEmplacement = NewLienObjetEmplacementClient(c.config) c.Objet = NewObjetClient(c.config) c.PieceJointe = NewPieceJointeClient(c.config) } type ( // config is the configuration for the client and its builder. config struct { // driver used for executing database requests. driver dialect.Driver // debug enable a debug logging. debug bool // log used for logging on debug mode. log func(...any) // hooks to execute on mutations. hooks *hooks // interceptors to execute on queries. inters *inters } // Option function to configure the client. Option func(*config) ) // newConfig creates a new config for the client. func newConfig(opts ...Option) config { cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} cfg.options(opts...) return cfg } // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { opt(c) } if c.debug { c.driver = dialect.Debug(c.driver, c.log) } } // Debug enables debug logging on the ent.Driver. func Debug() Option { return func(c *config) { c.debug = true } } // Log sets the logging function for debug mode. func Log(fn func(...any)) Option { return func(c *config) { c.log = fn } } // Driver configures the client driver. func Driver(driver dialect.Driver) Option { return func(c *config) { c.driver = driver } } // Open opens a database/sql.DB specified by the driver name and // the data source name, and returns a new client attached to it. // Optional parameters can be added for configuring the client. func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { switch driverName { case dialect.MySQL, dialect.Postgres, dialect.SQLite: drv, err := sql.Open(driverName, dataSourceName) if err != nil { return nil, err } return NewClient(append(options, Driver(drv))...), nil default: return nil, fmt.Errorf("unsupported driver: %q", driverName) } } // ErrTxStarted is returned when trying to start a new transaction from a transactional client. var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { return nil, fmt.Errorf("ent: starting a transaction: %w", err) } cfg := c.config cfg.driver = tx return &Tx{ ctx: ctx, config: cfg, Categorie: NewCategorieClient(cfg), ChampPersonnalise: NewChampPersonnaliseClient(cfg), Emplacement: NewEmplacementClient(cfg), LienObjetEmplacement: NewLienObjetEmplacementClient(cfg), Objet: NewObjetClient(cfg), PieceJointe: NewPieceJointeClient(cfg), }, nil } // BeginTx returns a transactional client with specified options. func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { return nil, errors.New("ent: cannot start a transaction within a transaction") } tx, err := c.driver.(interface { BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error) }).BeginTx(ctx, opts) if err != nil { return nil, fmt.Errorf("ent: starting a transaction: %w", err) } cfg := c.config cfg.driver = &txDriver{tx: tx, drv: c.driver} return &Tx{ ctx: ctx, config: cfg, Categorie: NewCategorieClient(cfg), ChampPersonnalise: NewChampPersonnaliseClient(cfg), Emplacement: NewEmplacementClient(cfg), LienObjetEmplacement: NewLienObjetEmplacementClient(cfg), Objet: NewObjetClient(cfg), PieceJointe: NewPieceJointeClient(cfg), }, nil } // Debug returns a new debug-client. It's used to get verbose logging on specific operations. // // client.Debug(). // Categorie. // Query(). // Count(ctx) func (c *Client) Debug() *Client { if c.debug { return c } cfg := c.config cfg.driver = dialect.Debug(c.driver, c.log) client := &Client{config: cfg} client.init() return client } // Close closes the database connection and prevents new queries from starting. func (c *Client) Close() error { return c.driver.Close() } // Use adds the mutation hooks to all the entity clients. // In order to add hooks to a specific client, call: `client.Node.Use(...)`. func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ c.Categorie, c.ChampPersonnalise, c.Emplacement, c.LienObjetEmplacement, c.Objet, c.PieceJointe, } { n.Use(hooks...) } } // Intercept adds the query interceptors to all the entity clients. // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ c.Categorie, c.ChampPersonnalise, c.Emplacement, c.LienObjetEmplacement, c.Objet, c.PieceJointe, } { n.Intercept(interceptors...) } } // Mutate implements the ent.Mutator interface. func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { switch m := m.(type) { case *CategorieMutation: return c.Categorie.mutate(ctx, m) case *ChampPersonnaliseMutation: return c.ChampPersonnalise.mutate(ctx, m) case *EmplacementMutation: return c.Emplacement.mutate(ctx, m) case *LienObjetEmplacementMutation: return c.LienObjetEmplacement.mutate(ctx, m) case *ObjetMutation: return c.Objet.mutate(ctx, m) case *PieceJointeMutation: return c.PieceJointe.mutate(ctx, m) default: return nil, fmt.Errorf("ent: unknown mutation type %T", m) } } // CategorieClient is a client for the Categorie schema. type CategorieClient struct { config } // NewCategorieClient returns a client for the Categorie from the given config. func NewCategorieClient(c config) *CategorieClient { return &CategorieClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `categorie.Hooks(f(g(h())))`. func (c *CategorieClient) Use(hooks ...Hook) { c.hooks.Categorie = append(c.hooks.Categorie, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `categorie.Intercept(f(g(h())))`. func (c *CategorieClient) Intercept(interceptors ...Interceptor) { c.inters.Categorie = append(c.inters.Categorie, interceptors...) } // Create returns a builder for creating a Categorie entity. func (c *CategorieClient) Create() *CategorieCreate { mutation := newCategorieMutation(c.config, OpCreate) return &CategorieCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Categorie entities. func (c *CategorieClient) CreateBulk(builders ...*CategorieCreate) *CategorieCreateBulk { return &CategorieCreateBulk{config: c.config, builders: builders} } // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates // a builder and applies setFunc on it. func (c *CategorieClient) MapCreateBulk(slice any, setFunc func(*CategorieCreate, int)) *CategorieCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &CategorieCreateBulk{err: fmt.Errorf("calling to CategorieClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*CategorieCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &CategorieCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Categorie. func (c *CategorieClient) Update() *CategorieUpdate { mutation := newCategorieMutation(c.config, OpUpdate) return &CategorieUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *CategorieClient) UpdateOne(_m *Categorie) *CategorieUpdateOne { mutation := newCategorieMutation(c.config, OpUpdateOne, withCategorie(_m)) return &CategorieUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *CategorieClient) UpdateOneID(id uuid.UUID) *CategorieUpdateOne { mutation := newCategorieMutation(c.config, OpUpdateOne, withCategorieID(id)) return &CategorieUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Categorie. func (c *CategorieClient) Delete() *CategorieDelete { mutation := newCategorieMutation(c.config, OpDelete) return &CategorieDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *CategorieClient) DeleteOne(_m *Categorie) *CategorieDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *CategorieClient) DeleteOneID(id uuid.UUID) *CategorieDeleteOne { builder := c.Delete().Where(categorie.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &CategorieDeleteOne{builder} } // Query returns a query builder for Categorie. func (c *CategorieClient) Query() *CategorieQuery { return &CategorieQuery{ config: c.config, ctx: &QueryContext{Type: TypeCategorie}, inters: c.Interceptors(), } } // Get returns a Categorie entity by its id. func (c *CategorieClient) Get(ctx context.Context, id uuid.UUID) (*Categorie, error) { return c.Query().Where(categorie.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *CategorieClient) GetX(ctx context.Context, id uuid.UUID) *Categorie { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryParent queries the parent edge of a Categorie. func (c *CategorieClient) QueryParent(_m *Categorie) *CategorieQuery { query := (&CategorieClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(categorie.Table, categorie.FieldID, id), sqlgraph.To(categorie.Table, categorie.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, categorie.ParentTable, categorie.ParentColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryEnfants queries the enfants edge of a Categorie. func (c *CategorieClient) QueryEnfants(_m *Categorie) *CategorieQuery { query := (&CategorieClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(categorie.Table, categorie.FieldID, id), sqlgraph.To(categorie.Table, categorie.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, categorie.EnfantsTable, categorie.EnfantsColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *CategorieClient) Hooks() []Hook { return c.hooks.Categorie } // Interceptors returns the client interceptors. func (c *CategorieClient) Interceptors() []Interceptor { return c.inters.Categorie } func (c *CategorieClient) mutate(ctx context.Context, m *CategorieMutation) (Value, error) { switch m.Op() { case OpCreate: return (&CategorieCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&CategorieUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&CategorieUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&CategorieDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Categorie mutation op: %q", m.Op()) } } // ChampPersonnaliseClient is a client for the ChampPersonnalise schema. type ChampPersonnaliseClient struct { config } // NewChampPersonnaliseClient returns a client for the ChampPersonnalise from the given config. func NewChampPersonnaliseClient(c config) *ChampPersonnaliseClient { return &ChampPersonnaliseClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `champpersonnalise.Hooks(f(g(h())))`. func (c *ChampPersonnaliseClient) Use(hooks ...Hook) { c.hooks.ChampPersonnalise = append(c.hooks.ChampPersonnalise, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `champpersonnalise.Intercept(f(g(h())))`. func (c *ChampPersonnaliseClient) Intercept(interceptors ...Interceptor) { c.inters.ChampPersonnalise = append(c.inters.ChampPersonnalise, interceptors...) } // Create returns a builder for creating a ChampPersonnalise entity. func (c *ChampPersonnaliseClient) Create() *ChampPersonnaliseCreate { mutation := newChampPersonnaliseMutation(c.config, OpCreate) return &ChampPersonnaliseCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of ChampPersonnalise entities. func (c *ChampPersonnaliseClient) CreateBulk(builders ...*ChampPersonnaliseCreate) *ChampPersonnaliseCreateBulk { return &ChampPersonnaliseCreateBulk{config: c.config, builders: builders} } // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates // a builder and applies setFunc on it. func (c *ChampPersonnaliseClient) MapCreateBulk(slice any, setFunc func(*ChampPersonnaliseCreate, int)) *ChampPersonnaliseCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &ChampPersonnaliseCreateBulk{err: fmt.Errorf("calling to ChampPersonnaliseClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*ChampPersonnaliseCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &ChampPersonnaliseCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for ChampPersonnalise. func (c *ChampPersonnaliseClient) Update() *ChampPersonnaliseUpdate { mutation := newChampPersonnaliseMutation(c.config, OpUpdate) return &ChampPersonnaliseUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *ChampPersonnaliseClient) UpdateOne(_m *ChampPersonnalise) *ChampPersonnaliseUpdateOne { mutation := newChampPersonnaliseMutation(c.config, OpUpdateOne, withChampPersonnalise(_m)) return &ChampPersonnaliseUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *ChampPersonnaliseClient) UpdateOneID(id uuid.UUID) *ChampPersonnaliseUpdateOne { mutation := newChampPersonnaliseMutation(c.config, OpUpdateOne, withChampPersonnaliseID(id)) return &ChampPersonnaliseUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for ChampPersonnalise. func (c *ChampPersonnaliseClient) Delete() *ChampPersonnaliseDelete { mutation := newChampPersonnaliseMutation(c.config, OpDelete) return &ChampPersonnaliseDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *ChampPersonnaliseClient) DeleteOne(_m *ChampPersonnalise) *ChampPersonnaliseDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *ChampPersonnaliseClient) DeleteOneID(id uuid.UUID) *ChampPersonnaliseDeleteOne { builder := c.Delete().Where(champpersonnalise.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &ChampPersonnaliseDeleteOne{builder} } // Query returns a query builder for ChampPersonnalise. func (c *ChampPersonnaliseClient) Query() *ChampPersonnaliseQuery { return &ChampPersonnaliseQuery{ config: c.config, ctx: &QueryContext{Type: TypeChampPersonnalise}, inters: c.Interceptors(), } } // Get returns a ChampPersonnalise entity by its id. func (c *ChampPersonnaliseClient) Get(ctx context.Context, id uuid.UUID) (*ChampPersonnalise, error) { return c.Query().Where(champpersonnalise.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *ChampPersonnaliseClient) GetX(ctx context.Context, id uuid.UUID) *ChampPersonnalise { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryObjet queries the objet edge of a ChampPersonnalise. func (c *ChampPersonnaliseClient) QueryObjet(_m *ChampPersonnalise) *ObjetQuery { query := (&ObjetClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(champpersonnalise.Table, champpersonnalise.FieldID, id), sqlgraph.To(objet.Table, objet.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, champpersonnalise.ObjetTable, champpersonnalise.ObjetColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *ChampPersonnaliseClient) Hooks() []Hook { return c.hooks.ChampPersonnalise } // Interceptors returns the client interceptors. func (c *ChampPersonnaliseClient) Interceptors() []Interceptor { return c.inters.ChampPersonnalise } func (c *ChampPersonnaliseClient) mutate(ctx context.Context, m *ChampPersonnaliseMutation) (Value, error) { switch m.Op() { case OpCreate: return (&ChampPersonnaliseCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&ChampPersonnaliseUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&ChampPersonnaliseUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&ChampPersonnaliseDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown ChampPersonnalise mutation op: %q", m.Op()) } } // EmplacementClient is a client for the Emplacement schema. type EmplacementClient struct { config } // NewEmplacementClient returns a client for the Emplacement from the given config. func NewEmplacementClient(c config) *EmplacementClient { return &EmplacementClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `emplacement.Hooks(f(g(h())))`. func (c *EmplacementClient) Use(hooks ...Hook) { c.hooks.Emplacement = append(c.hooks.Emplacement, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `emplacement.Intercept(f(g(h())))`. func (c *EmplacementClient) Intercept(interceptors ...Interceptor) { c.inters.Emplacement = append(c.inters.Emplacement, interceptors...) } // Create returns a builder for creating a Emplacement entity. func (c *EmplacementClient) Create() *EmplacementCreate { mutation := newEmplacementMutation(c.config, OpCreate) return &EmplacementCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Emplacement entities. func (c *EmplacementClient) CreateBulk(builders ...*EmplacementCreate) *EmplacementCreateBulk { return &EmplacementCreateBulk{config: c.config, builders: builders} } // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates // a builder and applies setFunc on it. func (c *EmplacementClient) MapCreateBulk(slice any, setFunc func(*EmplacementCreate, int)) *EmplacementCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &EmplacementCreateBulk{err: fmt.Errorf("calling to EmplacementClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*EmplacementCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &EmplacementCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Emplacement. func (c *EmplacementClient) Update() *EmplacementUpdate { mutation := newEmplacementMutation(c.config, OpUpdate) return &EmplacementUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *EmplacementClient) UpdateOne(_m *Emplacement) *EmplacementUpdateOne { mutation := newEmplacementMutation(c.config, OpUpdateOne, withEmplacement(_m)) return &EmplacementUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *EmplacementClient) UpdateOneID(id uuid.UUID) *EmplacementUpdateOne { mutation := newEmplacementMutation(c.config, OpUpdateOne, withEmplacementID(id)) return &EmplacementUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Emplacement. func (c *EmplacementClient) Delete() *EmplacementDelete { mutation := newEmplacementMutation(c.config, OpDelete) return &EmplacementDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *EmplacementClient) DeleteOne(_m *Emplacement) *EmplacementDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *EmplacementClient) DeleteOneID(id uuid.UUID) *EmplacementDeleteOne { builder := c.Delete().Where(emplacement.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &EmplacementDeleteOne{builder} } // Query returns a query builder for Emplacement. func (c *EmplacementClient) Query() *EmplacementQuery { return &EmplacementQuery{ config: c.config, ctx: &QueryContext{Type: TypeEmplacement}, inters: c.Interceptors(), } } // Get returns a Emplacement entity by its id. func (c *EmplacementClient) Get(ctx context.Context, id uuid.UUID) (*Emplacement, error) { return c.Query().Where(emplacement.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *EmplacementClient) GetX(ctx context.Context, id uuid.UUID) *Emplacement { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryParent queries the parent edge of a Emplacement. func (c *EmplacementClient) QueryParent(_m *Emplacement) *EmplacementQuery { query := (&EmplacementClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(emplacement.Table, emplacement.FieldID, id), sqlgraph.To(emplacement.Table, emplacement.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, emplacement.ParentTable, emplacement.ParentColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryEnfants queries the enfants edge of a Emplacement. func (c *EmplacementClient) QueryEnfants(_m *Emplacement) *EmplacementQuery { query := (&EmplacementClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(emplacement.Table, emplacement.FieldID, id), sqlgraph.To(emplacement.Table, emplacement.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, emplacement.EnfantsTable, emplacement.EnfantsColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryLiensObjets queries the liens_objets edge of a Emplacement. func (c *EmplacementClient) QueryLiensObjets(_m *Emplacement) *LienObjetEmplacementQuery { query := (&LienObjetEmplacementClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(emplacement.Table, emplacement.FieldID, id), sqlgraph.To(lienobjetemplacement.Table, lienobjetemplacement.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, emplacement.LiensObjetsTable, emplacement.LiensObjetsColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *EmplacementClient) Hooks() []Hook { return c.hooks.Emplacement } // Interceptors returns the client interceptors. func (c *EmplacementClient) Interceptors() []Interceptor { return c.inters.Emplacement } func (c *EmplacementClient) mutate(ctx context.Context, m *EmplacementMutation) (Value, error) { switch m.Op() { case OpCreate: return (&EmplacementCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&EmplacementUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&EmplacementUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&EmplacementDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Emplacement mutation op: %q", m.Op()) } } // LienObjetEmplacementClient is a client for the LienObjetEmplacement schema. type LienObjetEmplacementClient struct { config } // NewLienObjetEmplacementClient returns a client for the LienObjetEmplacement from the given config. func NewLienObjetEmplacementClient(c config) *LienObjetEmplacementClient { return &LienObjetEmplacementClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `lienobjetemplacement.Hooks(f(g(h())))`. func (c *LienObjetEmplacementClient) Use(hooks ...Hook) { c.hooks.LienObjetEmplacement = append(c.hooks.LienObjetEmplacement, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `lienobjetemplacement.Intercept(f(g(h())))`. func (c *LienObjetEmplacementClient) Intercept(interceptors ...Interceptor) { c.inters.LienObjetEmplacement = append(c.inters.LienObjetEmplacement, interceptors...) } // Create returns a builder for creating a LienObjetEmplacement entity. func (c *LienObjetEmplacementClient) Create() *LienObjetEmplacementCreate { mutation := newLienObjetEmplacementMutation(c.config, OpCreate) return &LienObjetEmplacementCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of LienObjetEmplacement entities. func (c *LienObjetEmplacementClient) CreateBulk(builders ...*LienObjetEmplacementCreate) *LienObjetEmplacementCreateBulk { return &LienObjetEmplacementCreateBulk{config: c.config, builders: builders} } // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates // a builder and applies setFunc on it. func (c *LienObjetEmplacementClient) MapCreateBulk(slice any, setFunc func(*LienObjetEmplacementCreate, int)) *LienObjetEmplacementCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &LienObjetEmplacementCreateBulk{err: fmt.Errorf("calling to LienObjetEmplacementClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*LienObjetEmplacementCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &LienObjetEmplacementCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for LienObjetEmplacement. func (c *LienObjetEmplacementClient) Update() *LienObjetEmplacementUpdate { mutation := newLienObjetEmplacementMutation(c.config, OpUpdate) return &LienObjetEmplacementUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *LienObjetEmplacementClient) UpdateOne(_m *LienObjetEmplacement) *LienObjetEmplacementUpdateOne { mutation := newLienObjetEmplacementMutation(c.config, OpUpdateOne, withLienObjetEmplacement(_m)) return &LienObjetEmplacementUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *LienObjetEmplacementClient) UpdateOneID(id uuid.UUID) *LienObjetEmplacementUpdateOne { mutation := newLienObjetEmplacementMutation(c.config, OpUpdateOne, withLienObjetEmplacementID(id)) return &LienObjetEmplacementUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for LienObjetEmplacement. func (c *LienObjetEmplacementClient) Delete() *LienObjetEmplacementDelete { mutation := newLienObjetEmplacementMutation(c.config, OpDelete) return &LienObjetEmplacementDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *LienObjetEmplacementClient) DeleteOne(_m *LienObjetEmplacement) *LienObjetEmplacementDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *LienObjetEmplacementClient) DeleteOneID(id uuid.UUID) *LienObjetEmplacementDeleteOne { builder := c.Delete().Where(lienobjetemplacement.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &LienObjetEmplacementDeleteOne{builder} } // Query returns a query builder for LienObjetEmplacement. func (c *LienObjetEmplacementClient) Query() *LienObjetEmplacementQuery { return &LienObjetEmplacementQuery{ config: c.config, ctx: &QueryContext{Type: TypeLienObjetEmplacement}, inters: c.Interceptors(), } } // Get returns a LienObjetEmplacement entity by its id. func (c *LienObjetEmplacementClient) Get(ctx context.Context, id uuid.UUID) (*LienObjetEmplacement, error) { return c.Query().Where(lienobjetemplacement.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *LienObjetEmplacementClient) GetX(ctx context.Context, id uuid.UUID) *LienObjetEmplacement { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryObjet queries the objet edge of a LienObjetEmplacement. func (c *LienObjetEmplacementClient) QueryObjet(_m *LienObjetEmplacement) *ObjetQuery { query := (&ObjetClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(lienobjetemplacement.Table, lienobjetemplacement.FieldID, id), sqlgraph.To(objet.Table, objet.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, lienobjetemplacement.ObjetTable, lienobjetemplacement.ObjetColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryEmplacement queries the emplacement edge of a LienObjetEmplacement. func (c *LienObjetEmplacementClient) QueryEmplacement(_m *LienObjetEmplacement) *EmplacementQuery { query := (&EmplacementClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(lienobjetemplacement.Table, lienobjetemplacement.FieldID, id), sqlgraph.To(emplacement.Table, emplacement.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, lienobjetemplacement.EmplacementTable, lienobjetemplacement.EmplacementColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *LienObjetEmplacementClient) Hooks() []Hook { return c.hooks.LienObjetEmplacement } // Interceptors returns the client interceptors. func (c *LienObjetEmplacementClient) Interceptors() []Interceptor { return c.inters.LienObjetEmplacement } func (c *LienObjetEmplacementClient) mutate(ctx context.Context, m *LienObjetEmplacementMutation) (Value, error) { switch m.Op() { case OpCreate: return (&LienObjetEmplacementCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&LienObjetEmplacementUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&LienObjetEmplacementUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&LienObjetEmplacementDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown LienObjetEmplacement mutation op: %q", m.Op()) } } // ObjetClient is a client for the Objet schema. type ObjetClient struct { config } // NewObjetClient returns a client for the Objet from the given config. func NewObjetClient(c config) *ObjetClient { return &ObjetClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `objet.Hooks(f(g(h())))`. func (c *ObjetClient) Use(hooks ...Hook) { c.hooks.Objet = append(c.hooks.Objet, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `objet.Intercept(f(g(h())))`. func (c *ObjetClient) Intercept(interceptors ...Interceptor) { c.inters.Objet = append(c.inters.Objet, interceptors...) } // Create returns a builder for creating a Objet entity. func (c *ObjetClient) Create() *ObjetCreate { mutation := newObjetMutation(c.config, OpCreate) return &ObjetCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Objet entities. func (c *ObjetClient) CreateBulk(builders ...*ObjetCreate) *ObjetCreateBulk { return &ObjetCreateBulk{config: c.config, builders: builders} } // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates // a builder and applies setFunc on it. func (c *ObjetClient) MapCreateBulk(slice any, setFunc func(*ObjetCreate, int)) *ObjetCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &ObjetCreateBulk{err: fmt.Errorf("calling to ObjetClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*ObjetCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &ObjetCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Objet. func (c *ObjetClient) Update() *ObjetUpdate { mutation := newObjetMutation(c.config, OpUpdate) return &ObjetUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *ObjetClient) UpdateOne(_m *Objet) *ObjetUpdateOne { mutation := newObjetMutation(c.config, OpUpdateOne, withObjet(_m)) return &ObjetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *ObjetClient) UpdateOneID(id uuid.UUID) *ObjetUpdateOne { mutation := newObjetMutation(c.config, OpUpdateOne, withObjetID(id)) return &ObjetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Objet. func (c *ObjetClient) Delete() *ObjetDelete { mutation := newObjetMutation(c.config, OpDelete) return &ObjetDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *ObjetClient) DeleteOne(_m *Objet) *ObjetDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *ObjetClient) DeleteOneID(id uuid.UUID) *ObjetDeleteOne { builder := c.Delete().Where(objet.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &ObjetDeleteOne{builder} } // Query returns a query builder for Objet. func (c *ObjetClient) Query() *ObjetQuery { return &ObjetQuery{ config: c.config, ctx: &QueryContext{Type: TypeObjet}, inters: c.Interceptors(), } } // Get returns a Objet entity by its id. func (c *ObjetClient) Get(ctx context.Context, id uuid.UUID) (*Objet, error) { return c.Query().Where(objet.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *ObjetClient) GetX(ctx context.Context, id uuid.UUID) *Objet { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryLiensEmplacements queries the liens_emplacements edge of a Objet. func (c *ObjetClient) QueryLiensEmplacements(_m *Objet) *LienObjetEmplacementQuery { query := (&LienObjetEmplacementClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(objet.Table, objet.FieldID, id), sqlgraph.To(lienobjetemplacement.Table, lienobjetemplacement.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, objet.LiensEmplacementsTable, objet.LiensEmplacementsColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryChampsPersonnalises queries the champs_personnalises edge of a Objet. func (c *ObjetClient) QueryChampsPersonnalises(_m *Objet) *ChampPersonnaliseQuery { query := (&ChampPersonnaliseClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(objet.Table, objet.FieldID, id), sqlgraph.To(champpersonnalise.Table, champpersonnalise.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, objet.ChampsPersonnalisesTable, objet.ChampsPersonnalisesColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryPiecesJointes queries the pieces_jointes edge of a Objet. func (c *ObjetClient) QueryPiecesJointes(_m *Objet) *PieceJointeQuery { query := (&PieceJointeClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(objet.Table, objet.FieldID, id), sqlgraph.To(piecejointe.Table, piecejointe.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, objet.PiecesJointesTable, objet.PiecesJointesColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *ObjetClient) Hooks() []Hook { return c.hooks.Objet } // Interceptors returns the client interceptors. func (c *ObjetClient) Interceptors() []Interceptor { return c.inters.Objet } func (c *ObjetClient) mutate(ctx context.Context, m *ObjetMutation) (Value, error) { switch m.Op() { case OpCreate: return (&ObjetCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&ObjetUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&ObjetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&ObjetDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Objet mutation op: %q", m.Op()) } } // PieceJointeClient is a client for the PieceJointe schema. type PieceJointeClient struct { config } // NewPieceJointeClient returns a client for the PieceJointe from the given config. func NewPieceJointeClient(c config) *PieceJointeClient { return &PieceJointeClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `piecejointe.Hooks(f(g(h())))`. func (c *PieceJointeClient) Use(hooks ...Hook) { c.hooks.PieceJointe = append(c.hooks.PieceJointe, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `piecejointe.Intercept(f(g(h())))`. func (c *PieceJointeClient) Intercept(interceptors ...Interceptor) { c.inters.PieceJointe = append(c.inters.PieceJointe, interceptors...) } // Create returns a builder for creating a PieceJointe entity. func (c *PieceJointeClient) Create() *PieceJointeCreate { mutation := newPieceJointeMutation(c.config, OpCreate) return &PieceJointeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of PieceJointe entities. func (c *PieceJointeClient) CreateBulk(builders ...*PieceJointeCreate) *PieceJointeCreateBulk { return &PieceJointeCreateBulk{config: c.config, builders: builders} } // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates // a builder and applies setFunc on it. func (c *PieceJointeClient) MapCreateBulk(slice any, setFunc func(*PieceJointeCreate, int)) *PieceJointeCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &PieceJointeCreateBulk{err: fmt.Errorf("calling to PieceJointeClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*PieceJointeCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &PieceJointeCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for PieceJointe. func (c *PieceJointeClient) Update() *PieceJointeUpdate { mutation := newPieceJointeMutation(c.config, OpUpdate) return &PieceJointeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *PieceJointeClient) UpdateOne(_m *PieceJointe) *PieceJointeUpdateOne { mutation := newPieceJointeMutation(c.config, OpUpdateOne, withPieceJointe(_m)) return &PieceJointeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *PieceJointeClient) UpdateOneID(id uuid.UUID) *PieceJointeUpdateOne { mutation := newPieceJointeMutation(c.config, OpUpdateOne, withPieceJointeID(id)) return &PieceJointeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for PieceJointe. func (c *PieceJointeClient) Delete() *PieceJointeDelete { mutation := newPieceJointeMutation(c.config, OpDelete) return &PieceJointeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *PieceJointeClient) DeleteOne(_m *PieceJointe) *PieceJointeDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *PieceJointeClient) DeleteOneID(id uuid.UUID) *PieceJointeDeleteOne { builder := c.Delete().Where(piecejointe.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &PieceJointeDeleteOne{builder} } // Query returns a query builder for PieceJointe. func (c *PieceJointeClient) Query() *PieceJointeQuery { return &PieceJointeQuery{ config: c.config, ctx: &QueryContext{Type: TypePieceJointe}, inters: c.Interceptors(), } } // Get returns a PieceJointe entity by its id. func (c *PieceJointeClient) Get(ctx context.Context, id uuid.UUID) (*PieceJointe, error) { return c.Query().Where(piecejointe.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *PieceJointeClient) GetX(ctx context.Context, id uuid.UUID) *PieceJointe { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryObjet queries the objet edge of a PieceJointe. func (c *PieceJointeClient) QueryObjet(_m *PieceJointe) *ObjetQuery { query := (&ObjetClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(piecejointe.Table, piecejointe.FieldID, id), sqlgraph.To(objet.Table, objet.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, piecejointe.ObjetTable, piecejointe.ObjetColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *PieceJointeClient) Hooks() []Hook { return c.hooks.PieceJointe } // Interceptors returns the client interceptors. func (c *PieceJointeClient) Interceptors() []Interceptor { return c.inters.PieceJointe } func (c *PieceJointeClient) mutate(ctx context.Context, m *PieceJointeMutation) (Value, error) { switch m.Op() { case OpCreate: return (&PieceJointeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&PieceJointeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&PieceJointeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&PieceJointeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown PieceJointe mutation op: %q", m.Op()) } } // hooks and interceptors per client, for fast access. type ( hooks struct { Categorie, ChampPersonnalise, Emplacement, LienObjetEmplacement, Objet, PieceJointe []ent.Hook } inters struct { Categorie, ChampPersonnalise, Emplacement, LienObjetEmplacement, Objet, PieceJointe []ent.Interceptor } )