1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315
|
// 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"
"entgo.io/ent/entc/integration/edgefield/ent/migrate"
"github.com/google/uuid"
"entgo.io/ent/entc/integration/edgefield/ent/car"
"entgo.io/ent/entc/integration/edgefield/ent/card"
"entgo.io/ent/entc/integration/edgefield/ent/info"
"entgo.io/ent/entc/integration/edgefield/ent/metadata"
"entgo.io/ent/entc/integration/edgefield/ent/node"
"entgo.io/ent/entc/integration/edgefield/ent/pet"
"entgo.io/ent/entc/integration/edgefield/ent/post"
"entgo.io/ent/entc/integration/edgefield/ent/rental"
"entgo.io/ent/entc/integration/edgefield/ent/user"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
// 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
// Car is the client for interacting with the Car builders.
Car *CarClient
// Card is the client for interacting with the Card builders.
Card *CardClient
// Info is the client for interacting with the Info builders.
Info *InfoClient
// Metadata is the client for interacting with the Metadata builders.
Metadata *MetadataClient
// Node is the client for interacting with the Node builders.
Node *NodeClient
// Pet is the client for interacting with the Pet builders.
Pet *PetClient
// Post is the client for interacting with the Post builders.
Post *PostClient
// Rental is the client for interacting with the Rental builders.
Rental *RentalClient
// User is the client for interacting with the User builders.
User *UserClient
}
// NewClient creates a new client configured with the given options.
func NewClient(opts ...Option) *Client {
cfg := config{log: log.Println, hooks: &hooks{}}
cfg.options(opts...)
client := &Client{config: cfg}
client.init()
return client
}
func (c *Client) init() {
c.Schema = migrate.NewSchema(c.driver)
c.Car = NewCarClient(c.config)
c.Card = NewCardClient(c.config)
c.Info = NewInfoClient(c.config)
c.Metadata = NewMetadataClient(c.config)
c.Node = NewNodeClient(c.config)
c.Pet = NewPetClient(c.config)
c.Post = NewPostClient(c.config)
c.Rental = NewRentalClient(c.config)
c.User = NewUserClient(c.config)
}
// 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)
}
}
// 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, errors.New("ent: cannot start a transaction within a transaction")
}
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,
Car: NewCarClient(cfg),
Card: NewCardClient(cfg),
Info: NewInfoClient(cfg),
Metadata: NewMetadataClient(cfg),
Node: NewNodeClient(cfg),
Pet: NewPetClient(cfg),
Post: NewPostClient(cfg),
Rental: NewRentalClient(cfg),
User: NewUserClient(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,
Car: NewCarClient(cfg),
Card: NewCardClient(cfg),
Info: NewInfoClient(cfg),
Metadata: NewMetadataClient(cfg),
Node: NewNodeClient(cfg),
Pet: NewPetClient(cfg),
Post: NewPostClient(cfg),
Rental: NewRentalClient(cfg),
User: NewUserClient(cfg),
}, nil
}
// Debug returns a new debug-client. It's used to get verbose logging on specific operations.
//
// client.Debug().
// Car.
// 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) {
c.Car.Use(hooks...)
c.Card.Use(hooks...)
c.Info.Use(hooks...)
c.Metadata.Use(hooks...)
c.Node.Use(hooks...)
c.Pet.Use(hooks...)
c.Post.Use(hooks...)
c.Rental.Use(hooks...)
c.User.Use(hooks...)
}
// 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...)
}
// 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}
}
// 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(ca *Car) *CarUpdateOne {
mutation := newCarMutation(c.config, OpUpdateOne, withCar(ca))
return &CarUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *CarClient) UpdateOneID(id uuid.UUID) *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(ca *Car) *CarDeleteOne {
return c.DeleteOneID(ca.ID)
}
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *CarClient) DeleteOneID(id uuid.UUID) *CarDeleteOne {
builder := c.Delete().Where(car.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &CarDeleteOne{builder}
}
// Query returns a query builder for Car.
func (c *CarClient) Query() *CarQuery {
return &CarQuery{
config: c.config,
}
}
// Get returns a Car entity by its id.
func (c *CarClient) Get(ctx context.Context, id uuid.UUID) (*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 uuid.UUID) *Car {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryRentals queries the rentals edge of a Car.
func (c *CarClient) QueryRentals(ca *Car) *RentalQuery {
query := &RentalQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := ca.ID
step := sqlgraph.NewStep(
sqlgraph.From(car.Table, car.FieldID, id),
sqlgraph.To(rental.Table, rental.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, car.RentalsTable, car.RentalsColumn),
)
fromV = sqlgraph.Neighbors(ca.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *CarClient) Hooks() []Hook {
return c.hooks.Car
}
// CardClient is a client for the Card schema.
type CardClient struct {
config
}
// NewCardClient returns a client for the Card from the given config.
func NewCardClient(c config) *CardClient {
return &CardClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `card.Hooks(f(g(h())))`.
func (c *CardClient) Use(hooks ...Hook) {
c.hooks.Card = append(c.hooks.Card, hooks...)
}
// Create returns a builder for creating a Card entity.
func (c *CardClient) Create() *CardCreate {
mutation := newCardMutation(c.config, OpCreate)
return &CardCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of Card entities.
func (c *CardClient) CreateBulk(builders ...*CardCreate) *CardCreateBulk {
return &CardCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for Card.
func (c *CardClient) Update() *CardUpdate {
mutation := newCardMutation(c.config, OpUpdate)
return &CardUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *CardClient) UpdateOne(ca *Card) *CardUpdateOne {
mutation := newCardMutation(c.config, OpUpdateOne, withCard(ca))
return &CardUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *CardClient) UpdateOneID(id int) *CardUpdateOne {
mutation := newCardMutation(c.config, OpUpdateOne, withCardID(id))
return &CardUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for Card.
func (c *CardClient) Delete() *CardDelete {
mutation := newCardMutation(c.config, OpDelete)
return &CardDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *CardClient) DeleteOne(ca *Card) *CardDeleteOne {
return c.DeleteOneID(ca.ID)
}
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *CardClient) DeleteOneID(id int) *CardDeleteOne {
builder := c.Delete().Where(card.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &CardDeleteOne{builder}
}
// Query returns a query builder for Card.
func (c *CardClient) Query() *CardQuery {
return &CardQuery{
config: c.config,
}
}
// Get returns a Card entity by its id.
func (c *CardClient) Get(ctx context.Context, id int) (*Card, error) {
return c.Query().Where(card.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *CardClient) GetX(ctx context.Context, id int) *Card {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryOwner queries the owner edge of a Card.
func (c *CardClient) QueryOwner(ca *Card) *UserQuery {
query := &UserQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := ca.ID
step := sqlgraph.NewStep(
sqlgraph.From(card.Table, card.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.O2O, true, card.OwnerTable, card.OwnerColumn),
)
fromV = sqlgraph.Neighbors(ca.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *CardClient) Hooks() []Hook {
return c.hooks.Card
}
// InfoClient is a client for the Info schema.
type InfoClient struct {
config
}
// NewInfoClient returns a client for the Info from the given config.
func NewInfoClient(c config) *InfoClient {
return &InfoClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `info.Hooks(f(g(h())))`.
func (c *InfoClient) Use(hooks ...Hook) {
c.hooks.Info = append(c.hooks.Info, hooks...)
}
// Create returns a builder for creating a Info entity.
func (c *InfoClient) Create() *InfoCreate {
mutation := newInfoMutation(c.config, OpCreate)
return &InfoCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of Info entities.
func (c *InfoClient) CreateBulk(builders ...*InfoCreate) *InfoCreateBulk {
return &InfoCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for Info.
func (c *InfoClient) Update() *InfoUpdate {
mutation := newInfoMutation(c.config, OpUpdate)
return &InfoUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *InfoClient) UpdateOne(i *Info) *InfoUpdateOne {
mutation := newInfoMutation(c.config, OpUpdateOne, withInfo(i))
return &InfoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *InfoClient) UpdateOneID(id int) *InfoUpdateOne {
mutation := newInfoMutation(c.config, OpUpdateOne, withInfoID(id))
return &InfoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for Info.
func (c *InfoClient) Delete() *InfoDelete {
mutation := newInfoMutation(c.config, OpDelete)
return &InfoDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *InfoClient) DeleteOne(i *Info) *InfoDeleteOne {
return c.DeleteOneID(i.ID)
}
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *InfoClient) DeleteOneID(id int) *InfoDeleteOne {
builder := c.Delete().Where(info.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &InfoDeleteOne{builder}
}
// Query returns a query builder for Info.
func (c *InfoClient) Query() *InfoQuery {
return &InfoQuery{
config: c.config,
}
}
// Get returns a Info entity by its id.
func (c *InfoClient) Get(ctx context.Context, id int) (*Info, error) {
return c.Query().Where(info.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *InfoClient) GetX(ctx context.Context, id int) *Info {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryUser queries the user edge of a Info.
func (c *InfoClient) QueryUser(i *Info) *UserQuery {
query := &UserQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := i.ID
step := sqlgraph.NewStep(
sqlgraph.From(info.Table, info.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, info.UserTable, info.UserColumn),
)
fromV = sqlgraph.Neighbors(i.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *InfoClient) Hooks() []Hook {
return c.hooks.Info
}
// MetadataClient is a client for the Metadata schema.
type MetadataClient struct {
config
}
// NewMetadataClient returns a client for the Metadata from the given config.
func NewMetadataClient(c config) *MetadataClient {
return &MetadataClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `metadata.Hooks(f(g(h())))`.
func (c *MetadataClient) Use(hooks ...Hook) {
c.hooks.Metadata = append(c.hooks.Metadata, hooks...)
}
// Create returns a builder for creating a Metadata entity.
func (c *MetadataClient) Create() *MetadataCreate {
mutation := newMetadataMutation(c.config, OpCreate)
return &MetadataCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of Metadata entities.
func (c *MetadataClient) CreateBulk(builders ...*MetadataCreate) *MetadataCreateBulk {
return &MetadataCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for Metadata.
func (c *MetadataClient) Update() *MetadataUpdate {
mutation := newMetadataMutation(c.config, OpUpdate)
return &MetadataUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *MetadataClient) UpdateOne(m *Metadata) *MetadataUpdateOne {
mutation := newMetadataMutation(c.config, OpUpdateOne, withMetadata(m))
return &MetadataUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *MetadataClient) UpdateOneID(id int) *MetadataUpdateOne {
mutation := newMetadataMutation(c.config, OpUpdateOne, withMetadataID(id))
return &MetadataUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for Metadata.
func (c *MetadataClient) Delete() *MetadataDelete {
mutation := newMetadataMutation(c.config, OpDelete)
return &MetadataDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *MetadataClient) DeleteOne(m *Metadata) *MetadataDeleteOne {
return c.DeleteOneID(m.ID)
}
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *MetadataClient) DeleteOneID(id int) *MetadataDeleteOne {
builder := c.Delete().Where(metadata.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &MetadataDeleteOne{builder}
}
// Query returns a query builder for Metadata.
func (c *MetadataClient) Query() *MetadataQuery {
return &MetadataQuery{
config: c.config,
}
}
// Get returns a Metadata entity by its id.
func (c *MetadataClient) Get(ctx context.Context, id int) (*Metadata, error) {
return c.Query().Where(metadata.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *MetadataClient) GetX(ctx context.Context, id int) *Metadata {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryUser queries the user edge of a Metadata.
func (c *MetadataClient) QueryUser(m *Metadata) *UserQuery {
query := &UserQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := m.ID
step := sqlgraph.NewStep(
sqlgraph.From(metadata.Table, metadata.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.O2O, true, metadata.UserTable, metadata.UserColumn),
)
fromV = sqlgraph.Neighbors(m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryChildren queries the children edge of a Metadata.
func (c *MetadataClient) QueryChildren(m *Metadata) *MetadataQuery {
query := &MetadataQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := m.ID
step := sqlgraph.NewStep(
sqlgraph.From(metadata.Table, metadata.FieldID, id),
sqlgraph.To(metadata.Table, metadata.FieldID),
sqlgraph.Edge(sqlgraph.O2M, true, metadata.ChildrenTable, metadata.ChildrenColumn),
)
fromV = sqlgraph.Neighbors(m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryParent queries the parent edge of a Metadata.
func (c *MetadataClient) QueryParent(m *Metadata) *MetadataQuery {
query := &MetadataQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := m.ID
step := sqlgraph.NewStep(
sqlgraph.From(metadata.Table, metadata.FieldID, id),
sqlgraph.To(metadata.Table, metadata.FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, metadata.ParentTable, metadata.ParentColumn),
)
fromV = sqlgraph.Neighbors(m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *MetadataClient) Hooks() []Hook {
return c.hooks.Metadata
}
// NodeClient is a client for the Node schema.
type NodeClient struct {
config
}
// NewNodeClient returns a client for the Node from the given config.
func NewNodeClient(c config) *NodeClient {
return &NodeClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `node.Hooks(f(g(h())))`.
func (c *NodeClient) Use(hooks ...Hook) {
c.hooks.Node = append(c.hooks.Node, hooks...)
}
// Create returns a builder for creating a Node entity.
func (c *NodeClient) Create() *NodeCreate {
mutation := newNodeMutation(c.config, OpCreate)
return &NodeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of Node entities.
func (c *NodeClient) CreateBulk(builders ...*NodeCreate) *NodeCreateBulk {
return &NodeCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for Node.
func (c *NodeClient) Update() *NodeUpdate {
mutation := newNodeMutation(c.config, OpUpdate)
return &NodeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *NodeClient) UpdateOne(n *Node) *NodeUpdateOne {
mutation := newNodeMutation(c.config, OpUpdateOne, withNode(n))
return &NodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *NodeClient) UpdateOneID(id int) *NodeUpdateOne {
mutation := newNodeMutation(c.config, OpUpdateOne, withNodeID(id))
return &NodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for Node.
func (c *NodeClient) Delete() *NodeDelete {
mutation := newNodeMutation(c.config, OpDelete)
return &NodeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *NodeClient) DeleteOne(n *Node) *NodeDeleteOne {
return c.DeleteOneID(n.ID)
}
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *NodeClient) DeleteOneID(id int) *NodeDeleteOne {
builder := c.Delete().Where(node.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &NodeDeleteOne{builder}
}
// Query returns a query builder for Node.
func (c *NodeClient) Query() *NodeQuery {
return &NodeQuery{
config: c.config,
}
}
// Get returns a Node entity by its id.
func (c *NodeClient) Get(ctx context.Context, id int) (*Node, error) {
return c.Query().Where(node.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *NodeClient) GetX(ctx context.Context, id int) *Node {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryPrev queries the prev edge of a Node.
func (c *NodeClient) QueryPrev(n *Node) *NodeQuery {
query := &NodeQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := n.ID
step := sqlgraph.NewStep(
sqlgraph.From(node.Table, node.FieldID, id),
sqlgraph.To(node.Table, node.FieldID),
sqlgraph.Edge(sqlgraph.O2O, true, node.PrevTable, node.PrevColumn),
)
fromV = sqlgraph.Neighbors(n.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryNext queries the next edge of a Node.
func (c *NodeClient) QueryNext(n *Node) *NodeQuery {
query := &NodeQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := n.ID
step := sqlgraph.NewStep(
sqlgraph.From(node.Table, node.FieldID, id),
sqlgraph.To(node.Table, node.FieldID),
sqlgraph.Edge(sqlgraph.O2O, false, node.NextTable, node.NextColumn),
)
fromV = sqlgraph.Neighbors(n.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *NodeClient) Hooks() []Hook {
return c.hooks.Node
}
// 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...)
}
// 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}
}
// 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(pe *Pet) *PetUpdateOne {
mutation := newPetMutation(c.config, OpUpdateOne, withPet(pe))
return &PetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *PetClient) UpdateOneID(id int) *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(pe *Pet) *PetDeleteOne {
return c.DeleteOneID(pe.ID)
}
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *PetClient) DeleteOneID(id int) *PetDeleteOne {
builder := c.Delete().Where(pet.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &PetDeleteOne{builder}
}
// Query returns a query builder for Pet.
func (c *PetClient) Query() *PetQuery {
return &PetQuery{
config: c.config,
}
}
// Get returns a Pet entity by its id.
func (c *PetClient) Get(ctx context.Context, id int) (*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 int) *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(pe *Pet) *UserQuery {
query := &UserQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := pe.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(pe.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *PetClient) Hooks() []Hook {
return c.hooks.Pet
}
// PostClient is a client for the Post schema.
type PostClient struct {
config
}
// NewPostClient returns a client for the Post from the given config.
func NewPostClient(c config) *PostClient {
return &PostClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `post.Hooks(f(g(h())))`.
func (c *PostClient) Use(hooks ...Hook) {
c.hooks.Post = append(c.hooks.Post, hooks...)
}
// Create returns a builder for creating a Post entity.
func (c *PostClient) Create() *PostCreate {
mutation := newPostMutation(c.config, OpCreate)
return &PostCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of Post entities.
func (c *PostClient) CreateBulk(builders ...*PostCreate) *PostCreateBulk {
return &PostCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for Post.
func (c *PostClient) Update() *PostUpdate {
mutation := newPostMutation(c.config, OpUpdate)
return &PostUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *PostClient) UpdateOne(po *Post) *PostUpdateOne {
mutation := newPostMutation(c.config, OpUpdateOne, withPost(po))
return &PostUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *PostClient) UpdateOneID(id int) *PostUpdateOne {
mutation := newPostMutation(c.config, OpUpdateOne, withPostID(id))
return &PostUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for Post.
func (c *PostClient) Delete() *PostDelete {
mutation := newPostMutation(c.config, OpDelete)
return &PostDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *PostClient) DeleteOne(po *Post) *PostDeleteOne {
return c.DeleteOneID(po.ID)
}
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *PostClient) DeleteOneID(id int) *PostDeleteOne {
builder := c.Delete().Where(post.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &PostDeleteOne{builder}
}
// Query returns a query builder for Post.
func (c *PostClient) Query() *PostQuery {
return &PostQuery{
config: c.config,
}
}
// Get returns a Post entity by its id.
func (c *PostClient) Get(ctx context.Context, id int) (*Post, error) {
return c.Query().Where(post.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *PostClient) GetX(ctx context.Context, id int) *Post {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryAuthor queries the author edge of a Post.
func (c *PostClient) QueryAuthor(po *Post) *UserQuery {
query := &UserQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := po.ID
step := sqlgraph.NewStep(
sqlgraph.From(post.Table, post.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, post.AuthorTable, post.AuthorColumn),
)
fromV = sqlgraph.Neighbors(po.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *PostClient) Hooks() []Hook {
return c.hooks.Post
}
// RentalClient is a client for the Rental schema.
type RentalClient struct {
config
}
// NewRentalClient returns a client for the Rental from the given config.
func NewRentalClient(c config) *RentalClient {
return &RentalClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `rental.Hooks(f(g(h())))`.
func (c *RentalClient) Use(hooks ...Hook) {
c.hooks.Rental = append(c.hooks.Rental, hooks...)
}
// Create returns a builder for creating a Rental entity.
func (c *RentalClient) Create() *RentalCreate {
mutation := newRentalMutation(c.config, OpCreate)
return &RentalCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of Rental entities.
func (c *RentalClient) CreateBulk(builders ...*RentalCreate) *RentalCreateBulk {
return &RentalCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for Rental.
func (c *RentalClient) Update() *RentalUpdate {
mutation := newRentalMutation(c.config, OpUpdate)
return &RentalUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *RentalClient) UpdateOne(r *Rental) *RentalUpdateOne {
mutation := newRentalMutation(c.config, OpUpdateOne, withRental(r))
return &RentalUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *RentalClient) UpdateOneID(id int) *RentalUpdateOne {
mutation := newRentalMutation(c.config, OpUpdateOne, withRentalID(id))
return &RentalUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for Rental.
func (c *RentalClient) Delete() *RentalDelete {
mutation := newRentalMutation(c.config, OpDelete)
return &RentalDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *RentalClient) DeleteOne(r *Rental) *RentalDeleteOne {
return c.DeleteOneID(r.ID)
}
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *RentalClient) DeleteOneID(id int) *RentalDeleteOne {
builder := c.Delete().Where(rental.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &RentalDeleteOne{builder}
}
// Query returns a query builder for Rental.
func (c *RentalClient) Query() *RentalQuery {
return &RentalQuery{
config: c.config,
}
}
// Get returns a Rental entity by its id.
func (c *RentalClient) Get(ctx context.Context, id int) (*Rental, error) {
return c.Query().Where(rental.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *RentalClient) GetX(ctx context.Context, id int) *Rental {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryUser queries the user edge of a Rental.
func (c *RentalClient) QueryUser(r *Rental) *UserQuery {
query := &UserQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := r.ID
step := sqlgraph.NewStep(
sqlgraph.From(rental.Table, rental.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, rental.UserTable, rental.UserColumn),
)
fromV = sqlgraph.Neighbors(r.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryCar queries the car edge of a Rental.
func (c *RentalClient) QueryCar(r *Rental) *CarQuery {
query := &CarQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := r.ID
step := sqlgraph.NewStep(
sqlgraph.From(rental.Table, rental.FieldID, id),
sqlgraph.To(car.Table, car.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, rental.CarTable, rental.CarColumn),
)
fromV = sqlgraph.Neighbors(r.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *RentalClient) Hooks() []Hook {
return c.hooks.Rental
}
// 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...)
}
// 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}
}
// 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(u *User) *UserUpdateOne {
mutation := newUserMutation(c.config, OpUpdateOne, withUser(u))
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(u *User) *UserDeleteOne {
return c.DeleteOneID(u.ID)
}
// DeleteOne 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.op = OpDeleteOne
return &UserDeleteOne{builder}
}
// Query returns a query builder for User.
func (c *UserClient) Query() *UserQuery {
return &UserQuery{
config: c.config,
}
}
// 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
}
// QueryPets queries the pets edge of a User.
func (c *UserClient) QueryPets(u *User) *PetQuery {
query := &PetQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := u.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(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryParent queries the parent edge of a User.
func (c *UserClient) QueryParent(u *User) *UserQuery {
query := &UserQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := u.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(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryChildren queries the children edge of a User.
func (c *UserClient) QueryChildren(u *User) *UserQuery {
query := &UserQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := u.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(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QuerySpouse queries the spouse edge of a User.
func (c *UserClient) QuerySpouse(u *User) *UserQuery {
query := &UserQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := u.ID
step := sqlgraph.NewStep(
sqlgraph.From(user.Table, user.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.O2O, false, user.SpouseTable, user.SpouseColumn),
)
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryCard queries the card edge of a User.
func (c *UserClient) QueryCard(u *User) *CardQuery {
query := &CardQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := u.ID
step := sqlgraph.NewStep(
sqlgraph.From(user.Table, user.FieldID, id),
sqlgraph.To(card.Table, card.FieldID),
sqlgraph.Edge(sqlgraph.O2O, false, user.CardTable, user.CardColumn),
)
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryMetadata queries the metadata edge of a User.
func (c *UserClient) QueryMetadata(u *User) *MetadataQuery {
query := &MetadataQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := u.ID
step := sqlgraph.NewStep(
sqlgraph.From(user.Table, user.FieldID, id),
sqlgraph.To(metadata.Table, metadata.FieldID),
sqlgraph.Edge(sqlgraph.O2O, false, user.MetadataTable, user.MetadataColumn),
)
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryInfo queries the info edge of a User.
func (c *UserClient) QueryInfo(u *User) *InfoQuery {
query := &InfoQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := u.ID
step := sqlgraph.NewStep(
sqlgraph.From(user.Table, user.FieldID, id),
sqlgraph.To(info.Table, info.FieldID),
sqlgraph.Edge(sqlgraph.O2M, true, user.InfoTable, user.InfoColumn),
)
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryRentals queries the rentals edge of a User.
func (c *UserClient) QueryRentals(u *User) *RentalQuery {
query := &RentalQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := u.ID
step := sqlgraph.NewStep(
sqlgraph.From(user.Table, user.FieldID, id),
sqlgraph.To(rental.Table, rental.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, user.RentalsTable, user.RentalsColumn),
)
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *UserClient) Hooks() []Hook {
return c.hooks.User
}
|