// Copyright 2019-present Facebook Inc. 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 ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "log" "reflect" "entgo.io/ent" "entgo.io/ent/entc/integration/customid/ent/migrate" "entgo.io/ent/entc/integration/customid/ent/schema" "entgo.io/ent/entc/integration/customid/sid" uuidc "entgo.io/ent/entc/integration/customid/uuidcompatible" "github.com/google/uuid" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/entc/integration/customid/ent/account" "entgo.io/ent/entc/integration/customid/ent/blob" "entgo.io/ent/entc/integration/customid/ent/bloblink" "entgo.io/ent/entc/integration/customid/ent/car" "entgo.io/ent/entc/integration/customid/ent/device" "entgo.io/ent/entc/integration/customid/ent/doc" "entgo.io/ent/entc/integration/customid/ent/group" "entgo.io/ent/entc/integration/customid/ent/intsid" "entgo.io/ent/entc/integration/customid/ent/link" "entgo.io/ent/entc/integration/customid/ent/mixinid" "entgo.io/ent/entc/integration/customid/ent/note" "entgo.io/ent/entc/integration/customid/ent/other" "entgo.io/ent/entc/integration/customid/ent/pet" "entgo.io/ent/entc/integration/customid/ent/revision" "entgo.io/ent/entc/integration/customid/ent/session" "entgo.io/ent/entc/integration/customid/ent/token" "entgo.io/ent/entc/integration/customid/ent/user" "entgo.io/ent/entc/integration/customid/ent/valuescan" ) // 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 // Account is the client for interacting with the Account builders. Account *AccountClient // Blob is the client for interacting with the Blob builders. Blob *BlobClient // BlobLink is the client for interacting with the BlobLink builders. BlobLink *BlobLinkClient // Car is the client for interacting with the Car builders. Car *CarClient // Device is the client for interacting with the Device builders. Device *DeviceClient // Doc is the client for interacting with the Doc builders. Doc *DocClient // Group is the client for interacting with the Group builders. Group *GroupClient // IntSID is the client for interacting with the IntSID builders. IntSID *IntSIDClient // Link is the client for interacting with the Link builders. Link *LinkClient // MixinID is the client for interacting with the MixinID builders. MixinID *MixinIDClient // Note is the client for interacting with the Note builders. Note *NoteClient // Other is the client for interacting with the Other builders. Other *OtherClient // Pet is the client for interacting with the Pet builders. Pet *PetClient // Revision is the client for interacting with the Revision builders. Revision *RevisionClient // Session is the client for interacting with the Session builders. Session *SessionClient // Token is the client for interacting with the Token builders. Token *TokenClient // User is the client for interacting with the User builders. User *UserClient // ValueScan is the client for interacting with the ValueScan builders. ValueScan *ValueScanClient } // 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.Account = NewAccountClient(c.config) c.Blob = NewBlobClient(c.config) c.BlobLink = NewBlobLinkClient(c.config) c.Car = NewCarClient(c.config) c.Device = NewDeviceClient(c.config) c.Doc = NewDocClient(c.config) c.Group = NewGroupClient(c.config) c.IntSID = NewIntSIDClient(c.config) c.Link = NewLinkClient(c.config) c.MixinID = NewMixinIDClient(c.config) c.Note = NewNoteClient(c.config) c.Other = NewOtherClient(c.config) c.Pet = NewPetClient(c.config) c.Revision = NewRevisionClient(c.config) c.Session = NewSessionClient(c.config) c.Token = NewTokenClient(c.config) c.User = NewUserClient(c.config) c.ValueScan = NewValueScanClient(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, Account: NewAccountClient(cfg), Blob: NewBlobClient(cfg), BlobLink: NewBlobLinkClient(cfg), Car: NewCarClient(cfg), Device: NewDeviceClient(cfg), Doc: NewDocClient(cfg), Group: NewGroupClient(cfg), IntSID: NewIntSIDClient(cfg), Link: NewLinkClient(cfg), MixinID: NewMixinIDClient(cfg), Note: NewNoteClient(cfg), Other: NewOtherClient(cfg), Pet: NewPetClient(cfg), Revision: NewRevisionClient(cfg), Session: NewSessionClient(cfg), Token: NewTokenClient(cfg), User: NewUserClient(cfg), ValueScan: NewValueScanClient(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, Account: NewAccountClient(cfg), Blob: NewBlobClient(cfg), BlobLink: NewBlobLinkClient(cfg), Car: NewCarClient(cfg), Device: NewDeviceClient(cfg), Doc: NewDocClient(cfg), Group: NewGroupClient(cfg), IntSID: NewIntSIDClient(cfg), Link: NewLinkClient(cfg), MixinID: NewMixinIDClient(cfg), Note: NewNoteClient(cfg), Other: NewOtherClient(cfg), Pet: NewPetClient(cfg), Revision: NewRevisionClient(cfg), Session: NewSessionClient(cfg), Token: NewTokenClient(cfg), User: NewUserClient(cfg), ValueScan: NewValueScanClient(cfg), }, nil } // Debug returns a new debug-client. It's used to get verbose logging on specific operations. // // client.Debug(). // Account. // 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.Account, c.Blob, c.BlobLink, c.Car, c.Device, c.Doc, c.Group, c.IntSID, c.Link, c.MixinID, c.Note, c.Other, c.Pet, c.Revision, c.Session, c.Token, c.User, c.ValueScan, } { 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.Account, c.Blob, c.BlobLink, c.Car, c.Device, c.Doc, c.Group, c.IntSID, c.Link, c.MixinID, c.Note, c.Other, c.Pet, c.Revision, c.Session, c.Token, c.User, c.ValueScan, } { 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 *AccountMutation: return c.Account.mutate(ctx, m) case *BlobMutation: return c.Blob.mutate(ctx, m) case *BlobLinkMutation: return c.BlobLink.mutate(ctx, m) case *CarMutation: return c.Car.mutate(ctx, m) case *DeviceMutation: return c.Device.mutate(ctx, m) case *DocMutation: return c.Doc.mutate(ctx, m) case *GroupMutation: return c.Group.mutate(ctx, m) case *IntSIDMutation: return c.IntSID.mutate(ctx, m) case *LinkMutation: return c.Link.mutate(ctx, m) case *MixinIDMutation: return c.MixinID.mutate(ctx, m) case *NoteMutation: return c.Note.mutate(ctx, m) case *OtherMutation: return c.Other.mutate(ctx, m) case *PetMutation: return c.Pet.mutate(ctx, m) case *RevisionMutation: return c.Revision.mutate(ctx, m) case *SessionMutation: return c.Session.mutate(ctx, m) case *TokenMutation: return c.Token.mutate(ctx, m) case *UserMutation: return c.User.mutate(ctx, m) case *ValueScanMutation: return c.ValueScan.mutate(ctx, m) default: return nil, fmt.Errorf("ent: unknown mutation type %T", m) } } // AccountClient is a client for the Account schema. type AccountClient struct { config } // NewAccountClient returns a client for the Account from the given config. func NewAccountClient(c config) *AccountClient { return &AccountClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `account.Hooks(f(g(h())))`. func (c *AccountClient) Use(hooks ...Hook) { c.hooks.Account = append(c.hooks.Account, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `account.Intercept(f(g(h())))`. func (c *AccountClient) Intercept(interceptors ...Interceptor) { c.inters.Account = append(c.inters.Account, interceptors...) } // Create returns a builder for creating a Account entity. func (c *AccountClient) Create() *AccountCreate { mutation := newAccountMutation(c.config, OpCreate) return &AccountCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Account entities. func (c *AccountClient) CreateBulk(builders ...*AccountCreate) *AccountCreateBulk { return &AccountCreateBulk{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 *AccountClient) MapCreateBulk(slice any, setFunc func(*AccountCreate, int)) *AccountCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &AccountCreateBulk{err: fmt.Errorf("calling to AccountClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*AccountCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &AccountCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Account. func (c *AccountClient) Update() *AccountUpdate { mutation := newAccountMutation(c.config, OpUpdate) return &AccountUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *AccountClient) UpdateOne(_m *Account) *AccountUpdateOne { mutation := newAccountMutation(c.config, OpUpdateOne, withAccount(_m)) return &AccountUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *AccountClient) UpdateOneID(id sid.ID) *AccountUpdateOne { mutation := newAccountMutation(c.config, OpUpdateOne, withAccountID(id)) return &AccountUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Account. func (c *AccountClient) Delete() *AccountDelete { mutation := newAccountMutation(c.config, OpDelete) return &AccountDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *AccountClient) DeleteOne(_m *Account) *AccountDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *AccountClient) DeleteOneID(id sid.ID) *AccountDeleteOne { builder := c.Delete().Where(account.ID(id)) builder.mutation.id = &id builder.mutation.SetOp(OpDeleteOne) return &AccountDeleteOne{builder} } // Query returns a query builder for Account. func (c *AccountClient) Query() *AccountQuery { return &AccountQuery{ config: c.config, ctx: &QueryContext{Type: TypeAccount}, inters: c.Interceptors(), } } // Get returns a Account entity by its id. func (c *AccountClient) Get(ctx context.Context, id sid.ID) (*Account, error) { return c.Query().Where(account.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *AccountClient) GetX(ctx context.Context, id sid.ID) *Account { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryToken queries the token edge of a Account. func (c *AccountClient) QueryToken(_m *Account) *TokenQuery { query := (&TokenClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(account.Table, account.FieldID, id), sqlgraph.To(token.Table, token.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, account.TokenTable, account.TokenColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *AccountClient) Hooks() []Hook { return c.hooks.Account } // Interceptors returns the client interceptors. func (c *AccountClient) Interceptors() []Interceptor { return c.inters.Account } func (c *AccountClient) mutate(ctx context.Context, m *AccountMutation) (Value, error) { switch m.Op() { case OpCreate: return (&AccountCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&AccountUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&AccountUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&AccountDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Account mutation op: %q", m.Op()) } } // BlobClient is a client for the Blob schema. type BlobClient struct { config } // NewBlobClient returns a client for the Blob from the given config. func NewBlobClient(c config) *BlobClient { return &BlobClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `blob.Hooks(f(g(h())))`. func (c *BlobClient) Use(hooks ...Hook) { c.hooks.Blob = append(c.hooks.Blob, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `blob.Intercept(f(g(h())))`. func (c *BlobClient) Intercept(interceptors ...Interceptor) { c.inters.Blob = append(c.inters.Blob, interceptors...) } // Create returns a builder for creating a Blob entity. func (c *BlobClient) Create() *BlobCreate { mutation := newBlobMutation(c.config, OpCreate) return &BlobCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Blob entities. func (c *BlobClient) CreateBulk(builders ...*BlobCreate) *BlobCreateBulk { return &BlobCreateBulk{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 *BlobClient) MapCreateBulk(slice any, setFunc func(*BlobCreate, int)) *BlobCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &BlobCreateBulk{err: fmt.Errorf("calling to BlobClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*BlobCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &BlobCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Blob. func (c *BlobClient) Update() *BlobUpdate { mutation := newBlobMutation(c.config, OpUpdate) return &BlobUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *BlobClient) UpdateOne(_m *Blob) *BlobUpdateOne { mutation := newBlobMutation(c.config, OpUpdateOne, withBlob(_m)) return &BlobUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *BlobClient) UpdateOneID(id uuid.UUID) *BlobUpdateOne { mutation := newBlobMutation(c.config, OpUpdateOne, withBlobID(id)) return &BlobUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Blob. func (c *BlobClient) Delete() *BlobDelete { mutation := newBlobMutation(c.config, OpDelete) return &BlobDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *BlobClient) DeleteOne(_m *Blob) *BlobDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *BlobClient) DeleteOneID(id uuid.UUID) *BlobDeleteOne { builder := c.Delete().Where(blob.ID(id)) builder.mutation.id = &id builder.mutation.SetOp(OpDeleteOne) return &BlobDeleteOne{builder} } // Query returns a query builder for Blob. func (c *BlobClient) Query() *BlobQuery { return &BlobQuery{ config: c.config, ctx: &QueryContext{Type: TypeBlob}, inters: c.Interceptors(), } } // Get returns a Blob entity by its id. func (c *BlobClient) Get(ctx context.Context, id uuid.UUID) (*Blob, error) { return c.Query().Where(blob.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *BlobClient) GetX(ctx context.Context, id uuid.UUID) *Blob { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryParent queries the parent edge of a Blob. func (c *BlobClient) QueryParent(_m *Blob) *BlobQuery { query := (&BlobClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(blob.Table, blob.FieldID, id), sqlgraph.To(blob.Table, blob.FieldID), sqlgraph.Edge(sqlgraph.O2O, false, blob.ParentTable, blob.ParentColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryLinks queries the links edge of a Blob. func (c *BlobClient) QueryLinks(_m *Blob) *BlobQuery { query := (&BlobClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(blob.Table, blob.FieldID, id), sqlgraph.To(blob.Table, blob.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, blob.LinksTable, blob.LinksPrimaryKey...), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryBlobLinks queries the blob_links edge of a Blob. func (c *BlobClient) QueryBlobLinks(_m *Blob) *BlobLinkQuery { query := (&BlobLinkClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(blob.Table, blob.FieldID, id), sqlgraph.To(bloblink.Table, bloblink.BlobColumn), sqlgraph.Edge(sqlgraph.O2M, true, blob.BlobLinksTable, blob.BlobLinksColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *BlobClient) Hooks() []Hook { return c.hooks.Blob } // Interceptors returns the client interceptors. func (c *BlobClient) Interceptors() []Interceptor { return c.inters.Blob } func (c *BlobClient) mutate(ctx context.Context, m *BlobMutation) (Value, error) { switch m.Op() { case OpCreate: return (&BlobCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&BlobUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&BlobUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&BlobDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Blob mutation op: %q", m.Op()) } } // BlobLinkClient is a client for the BlobLink schema. type BlobLinkClient struct { config } // NewBlobLinkClient returns a client for the BlobLink from the given config. func NewBlobLinkClient(c config) *BlobLinkClient { return &BlobLinkClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `bloblink.Hooks(f(g(h())))`. func (c *BlobLinkClient) Use(hooks ...Hook) { c.hooks.BlobLink = append(c.hooks.BlobLink, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `bloblink.Intercept(f(g(h())))`. func (c *BlobLinkClient) Intercept(interceptors ...Interceptor) { c.inters.BlobLink = append(c.inters.BlobLink, interceptors...) } // Create returns a builder for creating a BlobLink entity. func (c *BlobLinkClient) Create() *BlobLinkCreate { mutation := newBlobLinkMutation(c.config, OpCreate) return &BlobLinkCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of BlobLink entities. func (c *BlobLinkClient) CreateBulk(builders ...*BlobLinkCreate) *BlobLinkCreateBulk { return &BlobLinkCreateBulk{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 *BlobLinkClient) MapCreateBulk(slice any, setFunc func(*BlobLinkCreate, int)) *BlobLinkCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &BlobLinkCreateBulk{err: fmt.Errorf("calling to BlobLinkClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*BlobLinkCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &BlobLinkCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for BlobLink. func (c *BlobLinkClient) Update() *BlobLinkUpdate { mutation := newBlobLinkMutation(c.config, OpUpdate) return &BlobLinkUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *BlobLinkClient) UpdateOne(_m *BlobLink) *BlobLinkUpdateOne { mutation := newBlobLinkMutation(c.config, OpUpdateOne) mutation.SetBlobID(_m.BlobID) mutation.SetLinkID(_m.LinkID) return &BlobLinkUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for BlobLink. func (c *BlobLinkClient) Delete() *BlobLinkDelete { mutation := newBlobLinkMutation(c.config, OpDelete) return &BlobLinkDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Query returns a query builder for BlobLink. func (c *BlobLinkClient) Query() *BlobLinkQuery { return &BlobLinkQuery{ config: c.config, ctx: &QueryContext{Type: TypeBlobLink}, inters: c.Interceptors(), } } // QueryBlob queries the blob edge of a BlobLink. func (c *BlobLinkClient) QueryBlob(_m *BlobLink) *BlobQuery { return c.Query(). Where(bloblink.BlobID(_m.BlobID), bloblink.LinkID(_m.LinkID)). QueryBlob() } // QueryLink queries the link edge of a BlobLink. func (c *BlobLinkClient) QueryLink(_m *BlobLink) *BlobQuery { return c.Query(). Where(bloblink.BlobID(_m.BlobID), bloblink.LinkID(_m.LinkID)). QueryLink() } // Hooks returns the client hooks. func (c *BlobLinkClient) Hooks() []Hook { return c.hooks.BlobLink } // Interceptors returns the client interceptors. func (c *BlobLinkClient) Interceptors() []Interceptor { return c.inters.BlobLink } func (c *BlobLinkClient) mutate(ctx context.Context, m *BlobLinkMutation) (Value, error) { switch m.Op() { case OpCreate: return (&BlobLinkCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&BlobLinkUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&BlobLinkUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&BlobLinkDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown BlobLink mutation op: %q", m.Op()) } } // CarClient is a client for the Car schema. type CarClient struct { config } // NewCarClient returns a client for the Car from the given config. func NewCarClient(c config) *CarClient { return &CarClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `car.Hooks(f(g(h())))`. func (c *CarClient) Use(hooks ...Hook) { c.hooks.Car = append(c.hooks.Car, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `car.Intercept(f(g(h())))`. func (c *CarClient) Intercept(interceptors ...Interceptor) { c.inters.Car = append(c.inters.Car, interceptors...) } // Create returns a builder for creating a Car entity. func (c *CarClient) Create() *CarCreate { mutation := newCarMutation(c.config, OpCreate) return &CarCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Car entities. func (c *CarClient) CreateBulk(builders ...*CarCreate) *CarCreateBulk { return &CarCreateBulk{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 *CarClient) MapCreateBulk(slice any, setFunc func(*CarCreate, int)) *CarCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &CarCreateBulk{err: fmt.Errorf("calling to CarClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*CarCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &CarCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Car. func (c *CarClient) Update() *CarUpdate { mutation := newCarMutation(c.config, OpUpdate) return &CarUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *CarClient) UpdateOne(_m *Car) *CarUpdateOne { mutation := newCarMutation(c.config, OpUpdateOne, withCar(_m)) return &CarUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *CarClient) UpdateOneID(id int) *CarUpdateOne { mutation := newCarMutation(c.config, OpUpdateOne, withCarID(id)) return &CarUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Car. func (c *CarClient) Delete() *CarDelete { mutation := newCarMutation(c.config, OpDelete) return &CarDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *CarClient) DeleteOne(_m *Car) *CarDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *CarClient) DeleteOneID(id int) *CarDeleteOne { builder := c.Delete().Where(car.ID(id)) builder.mutation.id = &id builder.mutation.SetOp(OpDeleteOne) return &CarDeleteOne{builder} } // Query returns a query builder for Car. func (c *CarClient) Query() *CarQuery { return &CarQuery{ config: c.config, ctx: &QueryContext{Type: TypeCar}, inters: c.Interceptors(), } } // Get returns a Car entity by its id. func (c *CarClient) Get(ctx context.Context, id int) (*Car, error) { return c.Query().Where(car.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *CarClient) GetX(ctx context.Context, id int) *Car { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryOwner queries the owner edge of a Car. func (c *CarClient) QueryOwner(_m *Car) *PetQuery { query := (&PetClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(car.Table, car.FieldID, id), sqlgraph.To(pet.Table, pet.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, car.OwnerTable, car.OwnerColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *CarClient) Hooks() []Hook { return c.hooks.Car } // Interceptors returns the client interceptors. func (c *CarClient) Interceptors() []Interceptor { return c.inters.Car } func (c *CarClient) mutate(ctx context.Context, m *CarMutation) (Value, error) { switch m.Op() { case OpCreate: return (&CarCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&CarUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&CarUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&CarDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Car mutation op: %q", m.Op()) } } // DeviceClient is a client for the Device schema. type DeviceClient struct { config } // NewDeviceClient returns a client for the Device from the given config. func NewDeviceClient(c config) *DeviceClient { return &DeviceClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `device.Hooks(f(g(h())))`. func (c *DeviceClient) Use(hooks ...Hook) { c.hooks.Device = append(c.hooks.Device, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `device.Intercept(f(g(h())))`. func (c *DeviceClient) Intercept(interceptors ...Interceptor) { c.inters.Device = append(c.inters.Device, interceptors...) } // Create returns a builder for creating a Device entity. func (c *DeviceClient) Create() *DeviceCreate { mutation := newDeviceMutation(c.config, OpCreate) return &DeviceCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Device entities. func (c *DeviceClient) CreateBulk(builders ...*DeviceCreate) *DeviceCreateBulk { return &DeviceCreateBulk{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 *DeviceClient) MapCreateBulk(slice any, setFunc func(*DeviceCreate, int)) *DeviceCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &DeviceCreateBulk{err: fmt.Errorf("calling to DeviceClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*DeviceCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &DeviceCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Device. func (c *DeviceClient) Update() *DeviceUpdate { mutation := newDeviceMutation(c.config, OpUpdate) return &DeviceUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *DeviceClient) UpdateOne(_m *Device) *DeviceUpdateOne { mutation := newDeviceMutation(c.config, OpUpdateOne, withDevice(_m)) return &DeviceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *DeviceClient) UpdateOneID(id schema.ID) *DeviceUpdateOne { mutation := newDeviceMutation(c.config, OpUpdateOne, withDeviceID(id)) return &DeviceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Device. func (c *DeviceClient) Delete() *DeviceDelete { mutation := newDeviceMutation(c.config, OpDelete) return &DeviceDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *DeviceClient) DeleteOne(_m *Device) *DeviceDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *DeviceClient) DeleteOneID(id schema.ID) *DeviceDeleteOne { builder := c.Delete().Where(device.ID(id)) builder.mutation.id = &id builder.mutation.SetOp(OpDeleteOne) return &DeviceDeleteOne{builder} } // Query returns a query builder for Device. func (c *DeviceClient) Query() *DeviceQuery { return &DeviceQuery{ config: c.config, ctx: &QueryContext{Type: TypeDevice}, inters: c.Interceptors(), } } // Get returns a Device entity by its id. func (c *DeviceClient) Get(ctx context.Context, id schema.ID) (*Device, error) { return c.Query().Where(device.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *DeviceClient) GetX(ctx context.Context, id schema.ID) *Device { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryActiveSession queries the active_session edge of a Device. func (c *DeviceClient) QueryActiveSession(_m *Device) *SessionQuery { query := (&SessionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(device.Table, device.FieldID, id), sqlgraph.To(session.Table, session.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, device.ActiveSessionTable, device.ActiveSessionColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QuerySessions queries the sessions edge of a Device. func (c *DeviceClient) QuerySessions(_m *Device) *SessionQuery { query := (&SessionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(device.Table, device.FieldID, id), sqlgraph.To(session.Table, session.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, device.SessionsTable, device.SessionsColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *DeviceClient) Hooks() []Hook { return c.hooks.Device } // Interceptors returns the client interceptors. func (c *DeviceClient) Interceptors() []Interceptor { return c.inters.Device } func (c *DeviceClient) mutate(ctx context.Context, m *DeviceMutation) (Value, error) { switch m.Op() { case OpCreate: return (&DeviceCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&DeviceUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&DeviceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&DeviceDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Device mutation op: %q", m.Op()) } } // DocClient is a client for the Doc schema. type DocClient struct { config } // NewDocClient returns a client for the Doc from the given config. func NewDocClient(c config) *DocClient { return &DocClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `doc.Hooks(f(g(h())))`. func (c *DocClient) Use(hooks ...Hook) { c.hooks.Doc = append(c.hooks.Doc, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `doc.Intercept(f(g(h())))`. func (c *DocClient) Intercept(interceptors ...Interceptor) { c.inters.Doc = append(c.inters.Doc, interceptors...) } // Create returns a builder for creating a Doc entity. func (c *DocClient) Create() *DocCreate { mutation := newDocMutation(c.config, OpCreate) return &DocCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Doc entities. func (c *DocClient) CreateBulk(builders ...*DocCreate) *DocCreateBulk { return &DocCreateBulk{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 *DocClient) MapCreateBulk(slice any, setFunc func(*DocCreate, int)) *DocCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &DocCreateBulk{err: fmt.Errorf("calling to DocClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*DocCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &DocCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Doc. func (c *DocClient) Update() *DocUpdate { mutation := newDocMutation(c.config, OpUpdate) return &DocUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *DocClient) UpdateOne(_m *Doc) *DocUpdateOne { mutation := newDocMutation(c.config, OpUpdateOne, withDoc(_m)) return &DocUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *DocClient) UpdateOneID(id schema.DocID) *DocUpdateOne { mutation := newDocMutation(c.config, OpUpdateOne, withDocID(id)) return &DocUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Doc. func (c *DocClient) Delete() *DocDelete { mutation := newDocMutation(c.config, OpDelete) return &DocDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *DocClient) DeleteOne(_m *Doc) *DocDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *DocClient) DeleteOneID(id schema.DocID) *DocDeleteOne { builder := c.Delete().Where(doc.ID(id)) builder.mutation.id = &id builder.mutation.SetOp(OpDeleteOne) return &DocDeleteOne{builder} } // Query returns a query builder for Doc. func (c *DocClient) Query() *DocQuery { return &DocQuery{ config: c.config, ctx: &QueryContext{Type: TypeDoc}, inters: c.Interceptors(), } } // Get returns a Doc entity by its id. func (c *DocClient) Get(ctx context.Context, id schema.DocID) (*Doc, error) { return c.Query().Where(doc.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *DocClient) GetX(ctx context.Context, id schema.DocID) *Doc { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryParent queries the parent edge of a Doc. func (c *DocClient) QueryParent(_m *Doc) *DocQuery { query := (&DocClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(doc.Table, doc.FieldID, id), sqlgraph.To(doc.Table, doc.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, doc.ParentTable, doc.ParentColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryChildren queries the children edge of a Doc. func (c *DocClient) QueryChildren(_m *Doc) *DocQuery { query := (&DocClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(doc.Table, doc.FieldID, id), sqlgraph.To(doc.Table, doc.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, doc.ChildrenTable, doc.ChildrenColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryRelated queries the related edge of a Doc. func (c *DocClient) QueryRelated(_m *Doc) *DocQuery { query := (&DocClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(doc.Table, doc.FieldID, id), sqlgraph.To(doc.Table, doc.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, doc.RelatedTable, doc.RelatedPrimaryKey...), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *DocClient) Hooks() []Hook { return c.hooks.Doc } // Interceptors returns the client interceptors. func (c *DocClient) Interceptors() []Interceptor { return c.inters.Doc } func (c *DocClient) mutate(ctx context.Context, m *DocMutation) (Value, error) { switch m.Op() { case OpCreate: return (&DocCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&DocUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&DocUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&DocDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Doc mutation op: %q", m.Op()) } } // GroupClient is a client for the Group schema. type GroupClient struct { config } // NewGroupClient returns a client for the Group from the given config. func NewGroupClient(c config) *GroupClient { return &GroupClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `group.Hooks(f(g(h())))`. func (c *GroupClient) Use(hooks ...Hook) { c.hooks.Group = append(c.hooks.Group, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `group.Intercept(f(g(h())))`. func (c *GroupClient) Intercept(interceptors ...Interceptor) { c.inters.Group = append(c.inters.Group, interceptors...) } // Create returns a builder for creating a Group entity. func (c *GroupClient) Create() *GroupCreate { mutation := newGroupMutation(c.config, OpCreate) return &GroupCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Group entities. func (c *GroupClient) CreateBulk(builders ...*GroupCreate) *GroupCreateBulk { return &GroupCreateBulk{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 *GroupClient) MapCreateBulk(slice any, setFunc func(*GroupCreate, int)) *GroupCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &GroupCreateBulk{err: fmt.Errorf("calling to GroupClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*GroupCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &GroupCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Group. func (c *GroupClient) Update() *GroupUpdate { mutation := newGroupMutation(c.config, OpUpdate) return &GroupUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *GroupClient) UpdateOne(_m *Group) *GroupUpdateOne { mutation := newGroupMutation(c.config, OpUpdateOne, withGroup(_m)) return &GroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *GroupClient) UpdateOneID(id int) *GroupUpdateOne { mutation := newGroupMutation(c.config, OpUpdateOne, withGroupID(id)) return &GroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Group. func (c *GroupClient) Delete() *GroupDelete { mutation := newGroupMutation(c.config, OpDelete) return &GroupDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *GroupClient) DeleteOne(_m *Group) *GroupDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *GroupClient) DeleteOneID(id int) *GroupDeleteOne { builder := c.Delete().Where(group.ID(id)) builder.mutation.id = &id builder.mutation.SetOp(OpDeleteOne) return &GroupDeleteOne{builder} } // Query returns a query builder for Group. func (c *GroupClient) Query() *GroupQuery { return &GroupQuery{ config: c.config, ctx: &QueryContext{Type: TypeGroup}, inters: c.Interceptors(), } } // Get returns a Group entity by its id. func (c *GroupClient) Get(ctx context.Context, id int) (*Group, error) { return c.Query().Where(group.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *GroupClient) GetX(ctx context.Context, id int) *Group { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryUsers queries the users edge of a Group. func (c *GroupClient) QueryUsers(_m *Group) *UserQuery { query := (&UserClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(group.Table, group.FieldID, id), sqlgraph.To(user.Table, user.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, group.UsersTable, group.UsersPrimaryKey...), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *GroupClient) Hooks() []Hook { return c.hooks.Group } // Interceptors returns the client interceptors. func (c *GroupClient) Interceptors() []Interceptor { return c.inters.Group } func (c *GroupClient) mutate(ctx context.Context, m *GroupMutation) (Value, error) { switch m.Op() { case OpCreate: return (&GroupCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&GroupUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&GroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&GroupDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Group mutation op: %q", m.Op()) } } // IntSIDClient is a client for the IntSID schema. type IntSIDClient struct { config } // NewIntSIDClient returns a client for the IntSID from the given config. func NewIntSIDClient(c config) *IntSIDClient { return &IntSIDClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `intsid.Hooks(f(g(h())))`. func (c *IntSIDClient) Use(hooks ...Hook) { c.hooks.IntSID = append(c.hooks.IntSID, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `intsid.Intercept(f(g(h())))`. func (c *IntSIDClient) Intercept(interceptors ...Interceptor) { c.inters.IntSID = append(c.inters.IntSID, interceptors...) } // Create returns a builder for creating a IntSID entity. func (c *IntSIDClient) Create() *IntSIDCreate { mutation := newIntSIDMutation(c.config, OpCreate) return &IntSIDCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of IntSID entities. func (c *IntSIDClient) CreateBulk(builders ...*IntSIDCreate) *IntSIDCreateBulk { return &IntSIDCreateBulk{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 *IntSIDClient) MapCreateBulk(slice any, setFunc func(*IntSIDCreate, int)) *IntSIDCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &IntSIDCreateBulk{err: fmt.Errorf("calling to IntSIDClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*IntSIDCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &IntSIDCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for IntSID. func (c *IntSIDClient) Update() *IntSIDUpdate { mutation := newIntSIDMutation(c.config, OpUpdate) return &IntSIDUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *IntSIDClient) UpdateOne(_m *IntSID) *IntSIDUpdateOne { mutation := newIntSIDMutation(c.config, OpUpdateOne, withIntSID(_m)) return &IntSIDUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *IntSIDClient) UpdateOneID(id sid.ID) *IntSIDUpdateOne { mutation := newIntSIDMutation(c.config, OpUpdateOne, withIntSIDID(id)) return &IntSIDUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for IntSID. func (c *IntSIDClient) Delete() *IntSIDDelete { mutation := newIntSIDMutation(c.config, OpDelete) return &IntSIDDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *IntSIDClient) DeleteOne(_m *IntSID) *IntSIDDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *IntSIDClient) DeleteOneID(id sid.ID) *IntSIDDeleteOne { builder := c.Delete().Where(intsid.ID(id)) builder.mutation.id = &id builder.mutation.SetOp(OpDeleteOne) return &IntSIDDeleteOne{builder} } // Query returns a query builder for IntSID. func (c *IntSIDClient) Query() *IntSIDQuery { return &IntSIDQuery{ config: c.config, ctx: &QueryContext{Type: TypeIntSID}, inters: c.Interceptors(), } } // Get returns a IntSID entity by its id. func (c *IntSIDClient) Get(ctx context.Context, id sid.ID) (*IntSID, error) { return c.Query().Where(intsid.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *IntSIDClient) GetX(ctx context.Context, id sid.ID) *IntSID { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryParent queries the parent edge of a IntSID. func (c *IntSIDClient) QueryParent(_m *IntSID) *IntSIDQuery { query := (&IntSIDClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(intsid.Table, intsid.FieldID, id), sqlgraph.To(intsid.Table, intsid.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, intsid.ParentTable, intsid.ParentColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryChildren queries the children edge of a IntSID. func (c *IntSIDClient) QueryChildren(_m *IntSID) *IntSIDQuery { query := (&IntSIDClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(intsid.Table, intsid.FieldID, id), sqlgraph.To(intsid.Table, intsid.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, intsid.ChildrenTable, intsid.ChildrenColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *IntSIDClient) Hooks() []Hook { return c.hooks.IntSID } // Interceptors returns the client interceptors. func (c *IntSIDClient) Interceptors() []Interceptor { return c.inters.IntSID } func (c *IntSIDClient) mutate(ctx context.Context, m *IntSIDMutation) (Value, error) { switch m.Op() { case OpCreate: return (&IntSIDCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&IntSIDUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&IntSIDUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&IntSIDDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown IntSID mutation op: %q", m.Op()) } } // LinkClient is a client for the Link schema. type LinkClient struct { config } // NewLinkClient returns a client for the Link from the given config. func NewLinkClient(c config) *LinkClient { return &LinkClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `link.Hooks(f(g(h())))`. func (c *LinkClient) Use(hooks ...Hook) { c.hooks.Link = append(c.hooks.Link, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `link.Intercept(f(g(h())))`. func (c *LinkClient) Intercept(interceptors ...Interceptor) { c.inters.Link = append(c.inters.Link, interceptors...) } // Create returns a builder for creating a Link entity. func (c *LinkClient) Create() *LinkCreate { mutation := newLinkMutation(c.config, OpCreate) return &LinkCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Link entities. func (c *LinkClient) CreateBulk(builders ...*LinkCreate) *LinkCreateBulk { return &LinkCreateBulk{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 *LinkClient) MapCreateBulk(slice any, setFunc func(*LinkCreate, int)) *LinkCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &LinkCreateBulk{err: fmt.Errorf("calling to LinkClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*LinkCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &LinkCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Link. func (c *LinkClient) Update() *LinkUpdate { mutation := newLinkMutation(c.config, OpUpdate) return &LinkUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *LinkClient) UpdateOne(_m *Link) *LinkUpdateOne { mutation := newLinkMutation(c.config, OpUpdateOne, withLink(_m)) return &LinkUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *LinkClient) UpdateOneID(id uuidc.UUIDC) *LinkUpdateOne { mutation := newLinkMutation(c.config, OpUpdateOne, withLinkID(id)) return &LinkUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Link. func (c *LinkClient) Delete() *LinkDelete { mutation := newLinkMutation(c.config, OpDelete) return &LinkDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *LinkClient) DeleteOne(_m *Link) *LinkDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *LinkClient) DeleteOneID(id uuidc.UUIDC) *LinkDeleteOne { builder := c.Delete().Where(link.ID(id)) builder.mutation.id = &id builder.mutation.SetOp(OpDeleteOne) return &LinkDeleteOne{builder} } // Query returns a query builder for Link. func (c *LinkClient) Query() *LinkQuery { return &LinkQuery{ config: c.config, ctx: &QueryContext{Type: TypeLink}, inters: c.Interceptors(), } } // Get returns a Link entity by its id. func (c *LinkClient) Get(ctx context.Context, id uuidc.UUIDC) (*Link, error) { return c.Query().Where(link.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *LinkClient) GetX(ctx context.Context, id uuidc.UUIDC) *Link { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // Hooks returns the client hooks. func (c *LinkClient) Hooks() []Hook { return c.hooks.Link } // Interceptors returns the client interceptors. func (c *LinkClient) Interceptors() []Interceptor { return c.inters.Link } func (c *LinkClient) mutate(ctx context.Context, m *LinkMutation) (Value, error) { switch m.Op() { case OpCreate: return (&LinkCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&LinkUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&LinkUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&LinkDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Link mutation op: %q", m.Op()) } } // MixinIDClient is a client for the MixinID schema. type MixinIDClient struct { config } // NewMixinIDClient returns a client for the MixinID from the given config. func NewMixinIDClient(c config) *MixinIDClient { return &MixinIDClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `mixinid.Hooks(f(g(h())))`. func (c *MixinIDClient) Use(hooks ...Hook) { c.hooks.MixinID = append(c.hooks.MixinID, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `mixinid.Intercept(f(g(h())))`. func (c *MixinIDClient) Intercept(interceptors ...Interceptor) { c.inters.MixinID = append(c.inters.MixinID, interceptors...) } // Create returns a builder for creating a MixinID entity. func (c *MixinIDClient) Create() *MixinIDCreate { mutation := newMixinIDMutation(c.config, OpCreate) return &MixinIDCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of MixinID entities. func (c *MixinIDClient) CreateBulk(builders ...*MixinIDCreate) *MixinIDCreateBulk { return &MixinIDCreateBulk{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 *MixinIDClient) MapCreateBulk(slice any, setFunc func(*MixinIDCreate, int)) *MixinIDCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &MixinIDCreateBulk{err: fmt.Errorf("calling to MixinIDClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*MixinIDCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &MixinIDCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for MixinID. func (c *MixinIDClient) Update() *MixinIDUpdate { mutation := newMixinIDMutation(c.config, OpUpdate) return &MixinIDUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *MixinIDClient) UpdateOne(_m *MixinID) *MixinIDUpdateOne { mutation := newMixinIDMutation(c.config, OpUpdateOne, withMixinID(_m)) return &MixinIDUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *MixinIDClient) UpdateOneID(id uuid.UUID) *MixinIDUpdateOne { mutation := newMixinIDMutation(c.config, OpUpdateOne, withMixinIDID(id)) return &MixinIDUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for MixinID. func (c *MixinIDClient) Delete() *MixinIDDelete { mutation := newMixinIDMutation(c.config, OpDelete) return &MixinIDDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *MixinIDClient) DeleteOne(_m *MixinID) *MixinIDDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *MixinIDClient) DeleteOneID(id uuid.UUID) *MixinIDDeleteOne { builder := c.Delete().Where(mixinid.ID(id)) builder.mutation.id = &id builder.mutation.SetOp(OpDeleteOne) return &MixinIDDeleteOne{builder} } // Query returns a query builder for MixinID. func (c *MixinIDClient) Query() *MixinIDQuery { return &MixinIDQuery{ config: c.config, ctx: &QueryContext{Type: TypeMixinID}, inters: c.Interceptors(), } } // Get returns a MixinID entity by its id. func (c *MixinIDClient) Get(ctx context.Context, id uuid.UUID) (*MixinID, error) { return c.Query().Where(mixinid.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *MixinIDClient) GetX(ctx context.Context, id uuid.UUID) *MixinID { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // Hooks returns the client hooks. func (c *MixinIDClient) Hooks() []Hook { return c.hooks.MixinID } // Interceptors returns the client interceptors. func (c *MixinIDClient) Interceptors() []Interceptor { return c.inters.MixinID } func (c *MixinIDClient) mutate(ctx context.Context, m *MixinIDMutation) (Value, error) { switch m.Op() { case OpCreate: return (&MixinIDCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&MixinIDUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&MixinIDUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&MixinIDDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown MixinID mutation op: %q", m.Op()) } } // NoteClient is a client for the Note schema. type NoteClient struct { config } // NewNoteClient returns a client for the Note from the given config. func NewNoteClient(c config) *NoteClient { return &NoteClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `note.Hooks(f(g(h())))`. func (c *NoteClient) Use(hooks ...Hook) { c.hooks.Note = append(c.hooks.Note, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `note.Intercept(f(g(h())))`. func (c *NoteClient) Intercept(interceptors ...Interceptor) { c.inters.Note = append(c.inters.Note, interceptors...) } // Create returns a builder for creating a Note entity. func (c *NoteClient) Create() *NoteCreate { mutation := newNoteMutation(c.config, OpCreate) return &NoteCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Note entities. func (c *NoteClient) CreateBulk(builders ...*NoteCreate) *NoteCreateBulk { return &NoteCreateBulk{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 *NoteClient) MapCreateBulk(slice any, setFunc func(*NoteCreate, int)) *NoteCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &NoteCreateBulk{err: fmt.Errorf("calling to NoteClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*NoteCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &NoteCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Note. func (c *NoteClient) Update() *NoteUpdate { mutation := newNoteMutation(c.config, OpUpdate) return &NoteUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *NoteClient) UpdateOne(_m *Note) *NoteUpdateOne { mutation := newNoteMutation(c.config, OpUpdateOne, withNote(_m)) return &NoteUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *NoteClient) UpdateOneID(id schema.NoteID) *NoteUpdateOne { mutation := newNoteMutation(c.config, OpUpdateOne, withNoteID(id)) return &NoteUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Note. func (c *NoteClient) Delete() *NoteDelete { mutation := newNoteMutation(c.config, OpDelete) return &NoteDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *NoteClient) DeleteOne(_m *Note) *NoteDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *NoteClient) DeleteOneID(id schema.NoteID) *NoteDeleteOne { builder := c.Delete().Where(note.ID(id)) builder.mutation.id = &id builder.mutation.SetOp(OpDeleteOne) return &NoteDeleteOne{builder} } // Query returns a query builder for Note. func (c *NoteClient) Query() *NoteQuery { return &NoteQuery{ config: c.config, ctx: &QueryContext{Type: TypeNote}, inters: c.Interceptors(), } } // Get returns a Note entity by its id. func (c *NoteClient) Get(ctx context.Context, id schema.NoteID) (*Note, error) { return c.Query().Where(note.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *NoteClient) GetX(ctx context.Context, id schema.NoteID) *Note { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryParent queries the parent edge of a Note. func (c *NoteClient) QueryParent(_m *Note) *NoteQuery { query := (&NoteClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(note.Table, note.FieldID, id), sqlgraph.To(note.Table, note.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, note.ParentTable, note.ParentColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryChildren queries the children edge of a Note. func (c *NoteClient) QueryChildren(_m *Note) *NoteQuery { query := (&NoteClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(note.Table, note.FieldID, id), sqlgraph.To(note.Table, note.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, note.ChildrenTable, note.ChildrenColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *NoteClient) Hooks() []Hook { return c.hooks.Note } // Interceptors returns the client interceptors. func (c *NoteClient) Interceptors() []Interceptor { return c.inters.Note } func (c *NoteClient) mutate(ctx context.Context, m *NoteMutation) (Value, error) { switch m.Op() { case OpCreate: return (&NoteCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&NoteUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&NoteUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&NoteDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Note mutation op: %q", m.Op()) } } // OtherClient is a client for the Other schema. type OtherClient struct { config } // NewOtherClient returns a client for the Other from the given config. func NewOtherClient(c config) *OtherClient { return &OtherClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `other.Hooks(f(g(h())))`. func (c *OtherClient) Use(hooks ...Hook) { c.hooks.Other = append(c.hooks.Other, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `other.Intercept(f(g(h())))`. func (c *OtherClient) Intercept(interceptors ...Interceptor) { c.inters.Other = append(c.inters.Other, interceptors...) } // Create returns a builder for creating a Other entity. func (c *OtherClient) Create() *OtherCreate { mutation := newOtherMutation(c.config, OpCreate) return &OtherCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Other entities. func (c *OtherClient) CreateBulk(builders ...*OtherCreate) *OtherCreateBulk { return &OtherCreateBulk{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 *OtherClient) MapCreateBulk(slice any, setFunc func(*OtherCreate, int)) *OtherCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &OtherCreateBulk{err: fmt.Errorf("calling to OtherClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*OtherCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &OtherCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Other. func (c *OtherClient) Update() *OtherUpdate { mutation := newOtherMutation(c.config, OpUpdate) return &OtherUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *OtherClient) UpdateOne(_m *Other) *OtherUpdateOne { mutation := newOtherMutation(c.config, OpUpdateOne, withOther(_m)) return &OtherUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *OtherClient) UpdateOneID(id sid.ID) *OtherUpdateOne { mutation := newOtherMutation(c.config, OpUpdateOne, withOtherID(id)) return &OtherUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Other. func (c *OtherClient) Delete() *OtherDelete { mutation := newOtherMutation(c.config, OpDelete) return &OtherDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *OtherClient) DeleteOne(_m *Other) *OtherDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *OtherClient) DeleteOneID(id sid.ID) *OtherDeleteOne { builder := c.Delete().Where(other.ID(id)) builder.mutation.id = &id builder.mutation.SetOp(OpDeleteOne) return &OtherDeleteOne{builder} } // Query returns a query builder for Other. func (c *OtherClient) Query() *OtherQuery { return &OtherQuery{ config: c.config, ctx: &QueryContext{Type: TypeOther}, inters: c.Interceptors(), } } // Get returns a Other entity by its id. func (c *OtherClient) Get(ctx context.Context, id sid.ID) (*Other, error) { return c.Query().Where(other.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *OtherClient) GetX(ctx context.Context, id sid.ID) *Other { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // Hooks returns the client hooks. func (c *OtherClient) Hooks() []Hook { return c.hooks.Other } // Interceptors returns the client interceptors. func (c *OtherClient) Interceptors() []Interceptor { return c.inters.Other } func (c *OtherClient) mutate(ctx context.Context, m *OtherMutation) (Value, error) { switch m.Op() { case OpCreate: return (&OtherCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&OtherUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&OtherUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&OtherDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Other mutation op: %q", m.Op()) } } // PetClient is a client for the Pet schema. type PetClient struct { config } // NewPetClient returns a client for the Pet from the given config. func NewPetClient(c config) *PetClient { return &PetClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `pet.Hooks(f(g(h())))`. func (c *PetClient) Use(hooks ...Hook) { c.hooks.Pet = append(c.hooks.Pet, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `pet.Intercept(f(g(h())))`. func (c *PetClient) Intercept(interceptors ...Interceptor) { c.inters.Pet = append(c.inters.Pet, interceptors...) } // Create returns a builder for creating a Pet entity. func (c *PetClient) Create() *PetCreate { mutation := newPetMutation(c.config, OpCreate) return &PetCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Pet entities. func (c *PetClient) CreateBulk(builders ...*PetCreate) *PetCreateBulk { return &PetCreateBulk{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 *PetClient) MapCreateBulk(slice any, setFunc func(*PetCreate, int)) *PetCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &PetCreateBulk{err: fmt.Errorf("calling to PetClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*PetCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &PetCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Pet. func (c *PetClient) Update() *PetUpdate { mutation := newPetMutation(c.config, OpUpdate) return &PetUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *PetClient) UpdateOne(_m *Pet) *PetUpdateOne { mutation := newPetMutation(c.config, OpUpdateOne, withPet(_m)) return &PetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *PetClient) UpdateOneID(id string) *PetUpdateOne { mutation := newPetMutation(c.config, OpUpdateOne, withPetID(id)) return &PetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Pet. func (c *PetClient) Delete() *PetDelete { mutation := newPetMutation(c.config, OpDelete) return &PetDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *PetClient) DeleteOne(_m *Pet) *PetDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *PetClient) DeleteOneID(id string) *PetDeleteOne { builder := c.Delete().Where(pet.ID(id)) builder.mutation.id = &id builder.mutation.SetOp(OpDeleteOne) return &PetDeleteOne{builder} } // Query returns a query builder for Pet. func (c *PetClient) Query() *PetQuery { return &PetQuery{ config: c.config, ctx: &QueryContext{Type: TypePet}, inters: c.Interceptors(), } } // Get returns a Pet entity by its id. func (c *PetClient) Get(ctx context.Context, id string) (*Pet, error) { return c.Query().Where(pet.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *PetClient) GetX(ctx context.Context, id string) *Pet { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryOwner queries the owner edge of a Pet. func (c *PetClient) QueryOwner(_m *Pet) *UserQuery { query := (&UserClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(pet.Table, pet.FieldID, id), sqlgraph.To(user.Table, user.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, pet.OwnerTable, pet.OwnerColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryCars queries the cars edge of a Pet. func (c *PetClient) QueryCars(_m *Pet) *CarQuery { query := (&CarClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(pet.Table, pet.FieldID, id), sqlgraph.To(car.Table, car.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, pet.CarsTable, pet.CarsColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryFriends queries the friends edge of a Pet. func (c *PetClient) QueryFriends(_m *Pet) *PetQuery { query := (&PetClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(pet.Table, pet.FieldID, id), sqlgraph.To(pet.Table, pet.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, pet.FriendsTable, pet.FriendsPrimaryKey...), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryBestFriend queries the best_friend edge of a Pet. func (c *PetClient) QueryBestFriend(_m *Pet) *PetQuery { query := (&PetClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(pet.Table, pet.FieldID, id), sqlgraph.To(pet.Table, pet.FieldID), sqlgraph.Edge(sqlgraph.O2O, false, pet.BestFriendTable, pet.BestFriendColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *PetClient) Hooks() []Hook { return c.hooks.Pet } // Interceptors returns the client interceptors. func (c *PetClient) Interceptors() []Interceptor { return c.inters.Pet } func (c *PetClient) mutate(ctx context.Context, m *PetMutation) (Value, error) { switch m.Op() { case OpCreate: return (&PetCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&PetUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&PetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&PetDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Pet mutation op: %q", m.Op()) } } // RevisionClient is a client for the Revision schema. type RevisionClient struct { config } // NewRevisionClient returns a client for the Revision from the given config. func NewRevisionClient(c config) *RevisionClient { return &RevisionClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `revision.Hooks(f(g(h())))`. func (c *RevisionClient) Use(hooks ...Hook) { c.hooks.Revision = append(c.hooks.Revision, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `revision.Intercept(f(g(h())))`. func (c *RevisionClient) Intercept(interceptors ...Interceptor) { c.inters.Revision = append(c.inters.Revision, interceptors...) } // Create returns a builder for creating a Revision entity. func (c *RevisionClient) Create() *RevisionCreate { mutation := newRevisionMutation(c.config, OpCreate) return &RevisionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Revision entities. func (c *RevisionClient) CreateBulk(builders ...*RevisionCreate) *RevisionCreateBulk { return &RevisionCreateBulk{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 *RevisionClient) MapCreateBulk(slice any, setFunc func(*RevisionCreate, int)) *RevisionCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &RevisionCreateBulk{err: fmt.Errorf("calling to RevisionClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*RevisionCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &RevisionCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Revision. func (c *RevisionClient) Update() *RevisionUpdate { mutation := newRevisionMutation(c.config, OpUpdate) return &RevisionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *RevisionClient) UpdateOne(_m *Revision) *RevisionUpdateOne { mutation := newRevisionMutation(c.config, OpUpdateOne, withRevision(_m)) return &RevisionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *RevisionClient) UpdateOneID(id string) *RevisionUpdateOne { mutation := newRevisionMutation(c.config, OpUpdateOne, withRevisionID(id)) return &RevisionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Revision. func (c *RevisionClient) Delete() *RevisionDelete { mutation := newRevisionMutation(c.config, OpDelete) return &RevisionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *RevisionClient) DeleteOne(_m *Revision) *RevisionDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *RevisionClient) DeleteOneID(id string) *RevisionDeleteOne { builder := c.Delete().Where(revision.ID(id)) builder.mutation.id = &id builder.mutation.SetOp(OpDeleteOne) return &RevisionDeleteOne{builder} } // Query returns a query builder for Revision. func (c *RevisionClient) Query() *RevisionQuery { return &RevisionQuery{ config: c.config, ctx: &QueryContext{Type: TypeRevision}, inters: c.Interceptors(), } } // Get returns a Revision entity by its id. func (c *RevisionClient) Get(ctx context.Context, id string) (*Revision, error) { return c.Query().Where(revision.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *RevisionClient) GetX(ctx context.Context, id string) *Revision { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // Hooks returns the client hooks. func (c *RevisionClient) Hooks() []Hook { return c.hooks.Revision } // Interceptors returns the client interceptors. func (c *RevisionClient) Interceptors() []Interceptor { return c.inters.Revision } func (c *RevisionClient) mutate(ctx context.Context, m *RevisionMutation) (Value, error) { switch m.Op() { case OpCreate: return (&RevisionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&RevisionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&RevisionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&RevisionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Revision mutation op: %q", m.Op()) } } // SessionClient is a client for the Session schema. type SessionClient struct { config } // NewSessionClient returns a client for the Session from the given config. func NewSessionClient(c config) *SessionClient { return &SessionClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `session.Hooks(f(g(h())))`. func (c *SessionClient) Use(hooks ...Hook) { c.hooks.Session = append(c.hooks.Session, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `session.Intercept(f(g(h())))`. func (c *SessionClient) Intercept(interceptors ...Interceptor) { c.inters.Session = append(c.inters.Session, interceptors...) } // Create returns a builder for creating a Session entity. func (c *SessionClient) Create() *SessionCreate { mutation := newSessionMutation(c.config, OpCreate) return &SessionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Session entities. func (c *SessionClient) CreateBulk(builders ...*SessionCreate) *SessionCreateBulk { return &SessionCreateBulk{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 *SessionClient) MapCreateBulk(slice any, setFunc func(*SessionCreate, int)) *SessionCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &SessionCreateBulk{err: fmt.Errorf("calling to SessionClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*SessionCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &SessionCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Session. func (c *SessionClient) Update() *SessionUpdate { mutation := newSessionMutation(c.config, OpUpdate) return &SessionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *SessionClient) UpdateOne(_m *Session) *SessionUpdateOne { mutation := newSessionMutation(c.config, OpUpdateOne, withSession(_m)) return &SessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *SessionClient) UpdateOneID(id schema.ID) *SessionUpdateOne { mutation := newSessionMutation(c.config, OpUpdateOne, withSessionID(id)) return &SessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Session. func (c *SessionClient) Delete() *SessionDelete { mutation := newSessionMutation(c.config, OpDelete) return &SessionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *SessionClient) DeleteOne(_m *Session) *SessionDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *SessionClient) DeleteOneID(id schema.ID) *SessionDeleteOne { builder := c.Delete().Where(session.ID(id)) builder.mutation.id = &id builder.mutation.SetOp(OpDeleteOne) return &SessionDeleteOne{builder} } // Query returns a query builder for Session. func (c *SessionClient) Query() *SessionQuery { return &SessionQuery{ config: c.config, ctx: &QueryContext{Type: TypeSession}, inters: c.Interceptors(), } } // Get returns a Session entity by its id. func (c *SessionClient) Get(ctx context.Context, id schema.ID) (*Session, error) { return c.Query().Where(session.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *SessionClient) GetX(ctx context.Context, id schema.ID) *Session { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryDevice queries the device edge of a Session. func (c *SessionClient) QueryDevice(_m *Session) *DeviceQuery { query := (&DeviceClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(session.Table, session.FieldID, id), sqlgraph.To(device.Table, device.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, session.DeviceTable, session.DeviceColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *SessionClient) Hooks() []Hook { return c.hooks.Session } // Interceptors returns the client interceptors. func (c *SessionClient) Interceptors() []Interceptor { return c.inters.Session } func (c *SessionClient) mutate(ctx context.Context, m *SessionMutation) (Value, error) { switch m.Op() { case OpCreate: return (&SessionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&SessionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&SessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&SessionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Session mutation op: %q", m.Op()) } } // TokenClient is a client for the Token schema. type TokenClient struct { config } // NewTokenClient returns a client for the Token from the given config. func NewTokenClient(c config) *TokenClient { return &TokenClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `token.Hooks(f(g(h())))`. func (c *TokenClient) Use(hooks ...Hook) { c.hooks.Token = append(c.hooks.Token, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `token.Intercept(f(g(h())))`. func (c *TokenClient) Intercept(interceptors ...Interceptor) { c.inters.Token = append(c.inters.Token, interceptors...) } // Create returns a builder for creating a Token entity. func (c *TokenClient) Create() *TokenCreate { mutation := newTokenMutation(c.config, OpCreate) return &TokenCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Token entities. func (c *TokenClient) CreateBulk(builders ...*TokenCreate) *TokenCreateBulk { return &TokenCreateBulk{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 *TokenClient) MapCreateBulk(slice any, setFunc func(*TokenCreate, int)) *TokenCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &TokenCreateBulk{err: fmt.Errorf("calling to TokenClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*TokenCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &TokenCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Token. func (c *TokenClient) Update() *TokenUpdate { mutation := newTokenMutation(c.config, OpUpdate) return &TokenUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *TokenClient) UpdateOne(_m *Token) *TokenUpdateOne { mutation := newTokenMutation(c.config, OpUpdateOne, withToken(_m)) return &TokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *TokenClient) UpdateOneID(id sid.ID) *TokenUpdateOne { mutation := newTokenMutation(c.config, OpUpdateOne, withTokenID(id)) return &TokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Token. func (c *TokenClient) Delete() *TokenDelete { mutation := newTokenMutation(c.config, OpDelete) return &TokenDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *TokenClient) DeleteOne(_m *Token) *TokenDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *TokenClient) DeleteOneID(id sid.ID) *TokenDeleteOne { builder := c.Delete().Where(token.ID(id)) builder.mutation.id = &id builder.mutation.SetOp(OpDeleteOne) return &TokenDeleteOne{builder} } // Query returns a query builder for Token. func (c *TokenClient) Query() *TokenQuery { return &TokenQuery{ config: c.config, ctx: &QueryContext{Type: TypeToken}, inters: c.Interceptors(), } } // Get returns a Token entity by its id. func (c *TokenClient) Get(ctx context.Context, id sid.ID) (*Token, error) { return c.Query().Where(token.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *TokenClient) GetX(ctx context.Context, id sid.ID) *Token { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryAccount queries the account edge of a Token. func (c *TokenClient) QueryAccount(_m *Token) *AccountQuery { query := (&AccountClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(token.Table, token.FieldID, id), sqlgraph.To(account.Table, account.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, token.AccountTable, token.AccountColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *TokenClient) Hooks() []Hook { return c.hooks.Token } // Interceptors returns the client interceptors. func (c *TokenClient) Interceptors() []Interceptor { return c.inters.Token } func (c *TokenClient) mutate(ctx context.Context, m *TokenMutation) (Value, error) { switch m.Op() { case OpCreate: return (&TokenCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&TokenUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&TokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&TokenDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Token mutation op: %q", m.Op()) } } // UserClient is a client for the User schema. type UserClient struct { config } // NewUserClient returns a client for the User from the given config. func NewUserClient(c config) *UserClient { return &UserClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `user.Hooks(f(g(h())))`. func (c *UserClient) Use(hooks ...Hook) { c.hooks.User = append(c.hooks.User, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `user.Intercept(f(g(h())))`. func (c *UserClient) Intercept(interceptors ...Interceptor) { c.inters.User = append(c.inters.User, interceptors...) } // Create returns a builder for creating a User entity. func (c *UserClient) Create() *UserCreate { mutation := newUserMutation(c.config, OpCreate) return &UserCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of User entities. func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { return &UserCreateBulk{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 *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*UserCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &UserCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for User. func (c *UserClient) Update() *UserUpdate { mutation := newUserMutation(c.config, OpUpdate) return &UserUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *UserClient) UpdateOne(_m *User) *UserUpdateOne { mutation := newUserMutation(c.config, OpUpdateOne, withUser(_m)) return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *UserClient) UpdateOneID(id int) *UserUpdateOne { mutation := newUserMutation(c.config, OpUpdateOne, withUserID(id)) return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for User. func (c *UserClient) Delete() *UserDelete { mutation := newUserMutation(c.config, OpDelete) return &UserDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *UserClient) DeleteOne(_m *User) *UserDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *UserClient) DeleteOneID(id int) *UserDeleteOne { builder := c.Delete().Where(user.ID(id)) builder.mutation.id = &id builder.mutation.SetOp(OpDeleteOne) return &UserDeleteOne{builder} } // Query returns a query builder for User. func (c *UserClient) Query() *UserQuery { return &UserQuery{ config: c.config, ctx: &QueryContext{Type: TypeUser}, inters: c.Interceptors(), } } // Get returns a User entity by its id. func (c *UserClient) Get(ctx context.Context, id int) (*User, error) { return c.Query().Where(user.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *UserClient) GetX(ctx context.Context, id int) *User { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryGroups queries the groups edge of a User. func (c *UserClient) QueryGroups(_m *User) *GroupQuery { query := (&GroupClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(user.Table, user.FieldID, id), sqlgraph.To(group.Table, group.FieldID), sqlgraph.Edge(sqlgraph.M2M, true, user.GroupsTable, user.GroupsPrimaryKey...), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryParent queries the parent edge of a User. func (c *UserClient) QueryParent(_m *User) *UserQuery { query := (&UserClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(user.Table, user.FieldID, id), sqlgraph.To(user.Table, user.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, user.ParentTable, user.ParentColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryChildren queries the children edge of a User. func (c *UserClient) QueryChildren(_m *User) *UserQuery { query := (&UserClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(user.Table, user.FieldID, id), sqlgraph.To(user.Table, user.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, user.ChildrenTable, user.ChildrenColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryPets queries the pets edge of a User. func (c *UserClient) QueryPets(_m *User) *PetQuery { query := (&PetClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(user.Table, user.FieldID, id), sqlgraph.To(pet.Table, pet.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, user.PetsTable, user.PetsColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *UserClient) Hooks() []Hook { return c.hooks.User } // Interceptors returns the client interceptors. func (c *UserClient) Interceptors() []Interceptor { return c.inters.User } func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) { switch m.Op() { case OpCreate: return (&UserCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&UserUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&UserDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown User mutation op: %q", m.Op()) } } // ValueScanClient is a client for the ValueScan schema. type ValueScanClient struct { config } // NewValueScanClient returns a client for the ValueScan from the given config. func NewValueScanClient(c config) *ValueScanClient { return &ValueScanClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `valuescan.Hooks(f(g(h())))`. func (c *ValueScanClient) Use(hooks ...Hook) { c.hooks.ValueScan = append(c.hooks.ValueScan, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `valuescan.Intercept(f(g(h())))`. func (c *ValueScanClient) Intercept(interceptors ...Interceptor) { c.inters.ValueScan = append(c.inters.ValueScan, interceptors...) } // Create returns a builder for creating a ValueScan entity. func (c *ValueScanClient) Create() *ValueScanCreate { mutation := newValueScanMutation(c.config, OpCreate) return &ValueScanCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of ValueScan entities. func (c *ValueScanClient) CreateBulk(builders ...*ValueScanCreate) *ValueScanCreateBulk { return &ValueScanCreateBulk{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 *ValueScanClient) MapCreateBulk(slice any, setFunc func(*ValueScanCreate, int)) *ValueScanCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &ValueScanCreateBulk{err: fmt.Errorf("calling to ValueScanClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*ValueScanCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &ValueScanCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for ValueScan. func (c *ValueScanClient) Update() *ValueScanUpdate { mutation := newValueScanMutation(c.config, OpUpdate) return &ValueScanUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *ValueScanClient) UpdateOne(_m *ValueScan) *ValueScanUpdateOne { mutation := newValueScanMutation(c.config, OpUpdateOne, withValueScan(_m)) return &ValueScanUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *ValueScanClient) UpdateOneID(id schema.ValueScanID) *ValueScanUpdateOne { mutation := newValueScanMutation(c.config, OpUpdateOne, withValueScanID(id)) return &ValueScanUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for ValueScan. func (c *ValueScanClient) Delete() *ValueScanDelete { mutation := newValueScanMutation(c.config, OpDelete) return &ValueScanDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *ValueScanClient) DeleteOne(_m *ValueScan) *ValueScanDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *ValueScanClient) DeleteOneID(id schema.ValueScanID) *ValueScanDeleteOne { builder := c.Delete().Where(valuescan.ID(id)) builder.mutation.id = &id builder.mutation.SetOp(OpDeleteOne) return &ValueScanDeleteOne{builder} } // Query returns a query builder for ValueScan. func (c *ValueScanClient) Query() *ValueScanQuery { return &ValueScanQuery{ config: c.config, ctx: &QueryContext{Type: TypeValueScan}, inters: c.Interceptors(), } } // Get returns a ValueScan entity by its id. func (c *ValueScanClient) Get(ctx context.Context, id schema.ValueScanID) (*ValueScan, error) { return c.Query().Where(valuescan.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *ValueScanClient) GetX(ctx context.Context, id schema.ValueScanID) *ValueScan { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // Hooks returns the client hooks. func (c *ValueScanClient) Hooks() []Hook { return c.hooks.ValueScan } // Interceptors returns the client interceptors. func (c *ValueScanClient) Interceptors() []Interceptor { return c.inters.ValueScan } func (c *ValueScanClient) mutate(ctx context.Context, m *ValueScanMutation) (Value, error) { switch m.Op() { case OpCreate: return (&ValueScanCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&ValueScanUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&ValueScanUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&ValueScanDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown ValueScan mutation op: %q", m.Op()) } } // hooks and interceptors per client, for fast access. type ( hooks struct { Account, Blob, BlobLink, Car, Device, Doc, Group, IntSID, Link, MixinID, Note, Other, Pet, Revision, Session, Token, User, ValueScan []ent.Hook } inters struct { Account, Blob, BlobLink, Car, Device, Doc, Group, IntSID, Link, MixinID, Note, Other, Pet, Revision, Session, Token, User, ValueScan []ent.Interceptor } )