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 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853
|
// 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/edgeschema/ent/migrate"
"github.com/google/uuid"
"entgo.io/ent/entc/integration/edgeschema/ent/friendship"
"entgo.io/ent/entc/integration/edgeschema/ent/group"
"entgo.io/ent/entc/integration/edgeschema/ent/relationship"
"entgo.io/ent/entc/integration/edgeschema/ent/relationshipinfo"
"entgo.io/ent/entc/integration/edgeschema/ent/role"
"entgo.io/ent/entc/integration/edgeschema/ent/roleuser"
"entgo.io/ent/entc/integration/edgeschema/ent/tag"
"entgo.io/ent/entc/integration/edgeschema/ent/tweet"
"entgo.io/ent/entc/integration/edgeschema/ent/tweetlike"
"entgo.io/ent/entc/integration/edgeschema/ent/tweettag"
"entgo.io/ent/entc/integration/edgeschema/ent/user"
"entgo.io/ent/entc/integration/edgeschema/ent/usergroup"
"entgo.io/ent/entc/integration/edgeschema/ent/usertweet"
"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
// Friendship is the client for interacting with the Friendship builders.
Friendship *FriendshipClient
// Group is the client for interacting with the Group builders.
Group *GroupClient
// Relationship is the client for interacting with the Relationship builders.
Relationship *RelationshipClient
// RelationshipInfo is the client for interacting with the RelationshipInfo builders.
RelationshipInfo *RelationshipInfoClient
// Role is the client for interacting with the Role builders.
Role *RoleClient
// RoleUser is the client for interacting with the RoleUser builders.
RoleUser *RoleUserClient
// Tag is the client for interacting with the Tag builders.
Tag *TagClient
// Tweet is the client for interacting with the Tweet builders.
Tweet *TweetClient
// TweetLike is the client for interacting with the TweetLike builders.
TweetLike *TweetLikeClient
// TweetTag is the client for interacting with the TweetTag builders.
TweetTag *TweetTagClient
// User is the client for interacting with the User builders.
User *UserClient
// UserGroup is the client for interacting with the UserGroup builders.
UserGroup *UserGroupClient
// UserTweet is the client for interacting with the UserTweet builders.
UserTweet *UserTweetClient
}
// 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.Friendship = NewFriendshipClient(c.config)
c.Group = NewGroupClient(c.config)
c.Relationship = NewRelationshipClient(c.config)
c.RelationshipInfo = NewRelationshipInfoClient(c.config)
c.Role = NewRoleClient(c.config)
c.RoleUser = NewRoleUserClient(c.config)
c.Tag = NewTagClient(c.config)
c.Tweet = NewTweetClient(c.config)
c.TweetLike = NewTweetLikeClient(c.config)
c.TweetTag = NewTweetTagClient(c.config)
c.User = NewUserClient(c.config)
c.UserGroup = NewUserGroupClient(c.config)
c.UserTweet = NewUserTweetClient(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,
Friendship: NewFriendshipClient(cfg),
Group: NewGroupClient(cfg),
Relationship: NewRelationshipClient(cfg),
RelationshipInfo: NewRelationshipInfoClient(cfg),
Role: NewRoleClient(cfg),
RoleUser: NewRoleUserClient(cfg),
Tag: NewTagClient(cfg),
Tweet: NewTweetClient(cfg),
TweetLike: NewTweetLikeClient(cfg),
TweetTag: NewTweetTagClient(cfg),
User: NewUserClient(cfg),
UserGroup: NewUserGroupClient(cfg),
UserTweet: NewUserTweetClient(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,
Friendship: NewFriendshipClient(cfg),
Group: NewGroupClient(cfg),
Relationship: NewRelationshipClient(cfg),
RelationshipInfo: NewRelationshipInfoClient(cfg),
Role: NewRoleClient(cfg),
RoleUser: NewRoleUserClient(cfg),
Tag: NewTagClient(cfg),
Tweet: NewTweetClient(cfg),
TweetLike: NewTweetLikeClient(cfg),
TweetTag: NewTweetTagClient(cfg),
User: NewUserClient(cfg),
UserGroup: NewUserGroupClient(cfg),
UserTweet: NewUserTweetClient(cfg),
}, nil
}
// Debug returns a new debug-client. It's used to get verbose logging on specific operations.
//
// client.Debug().
// Friendship.
// 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.Friendship.Use(hooks...)
c.Group.Use(hooks...)
c.Relationship.Use(hooks...)
c.RelationshipInfo.Use(hooks...)
c.Role.Use(hooks...)
c.RoleUser.Use(hooks...)
c.Tag.Use(hooks...)
c.Tweet.Use(hooks...)
c.TweetLike.Use(hooks...)
c.TweetTag.Use(hooks...)
c.User.Use(hooks...)
c.UserGroup.Use(hooks...)
c.UserTweet.Use(hooks...)
}
// FriendshipClient is a client for the Friendship schema.
type FriendshipClient struct {
config
}
// NewFriendshipClient returns a client for the Friendship from the given config.
func NewFriendshipClient(c config) *FriendshipClient {
return &FriendshipClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `friendship.Hooks(f(g(h())))`.
func (c *FriendshipClient) Use(hooks ...Hook) {
c.hooks.Friendship = append(c.hooks.Friendship, hooks...)
}
// Create returns a builder for creating a Friendship entity.
func (c *FriendshipClient) Create() *FriendshipCreate {
mutation := newFriendshipMutation(c.config, OpCreate)
return &FriendshipCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of Friendship entities.
func (c *FriendshipClient) CreateBulk(builders ...*FriendshipCreate) *FriendshipCreateBulk {
return &FriendshipCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for Friendship.
func (c *FriendshipClient) Update() *FriendshipUpdate {
mutation := newFriendshipMutation(c.config, OpUpdate)
return &FriendshipUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *FriendshipClient) UpdateOne(f *Friendship) *FriendshipUpdateOne {
mutation := newFriendshipMutation(c.config, OpUpdateOne, withFriendship(f))
return &FriendshipUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *FriendshipClient) UpdateOneID(id int) *FriendshipUpdateOne {
mutation := newFriendshipMutation(c.config, OpUpdateOne, withFriendshipID(id))
return &FriendshipUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for Friendship.
func (c *FriendshipClient) Delete() *FriendshipDelete {
mutation := newFriendshipMutation(c.config, OpDelete)
return &FriendshipDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *FriendshipClient) DeleteOne(f *Friendship) *FriendshipDeleteOne {
return c.DeleteOneID(f.ID)
}
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *FriendshipClient) DeleteOneID(id int) *FriendshipDeleteOne {
builder := c.Delete().Where(friendship.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &FriendshipDeleteOne{builder}
}
// Query returns a query builder for Friendship.
func (c *FriendshipClient) Query() *FriendshipQuery {
return &FriendshipQuery{
config: c.config,
}
}
// Get returns a Friendship entity by its id.
func (c *FriendshipClient) Get(ctx context.Context, id int) (*Friendship, error) {
return c.Query().Where(friendship.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *FriendshipClient) GetX(ctx context.Context, id int) *Friendship {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryUser queries the user edge of a Friendship.
func (c *FriendshipClient) QueryUser(f *Friendship) *UserQuery {
query := &UserQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := f.ID
step := sqlgraph.NewStep(
sqlgraph.From(friendship.Table, friendship.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, friendship.UserTable, friendship.UserColumn),
)
fromV = sqlgraph.Neighbors(f.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryFriend queries the friend edge of a Friendship.
func (c *FriendshipClient) QueryFriend(f *Friendship) *UserQuery {
query := &UserQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := f.ID
step := sqlgraph.NewStep(
sqlgraph.From(friendship.Table, friendship.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, friendship.FriendTable, friendship.FriendColumn),
)
fromV = sqlgraph.Neighbors(f.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *FriendshipClient) Hooks() []Hook {
return c.hooks.Friendship
}
// 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...)
}
// 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}
}
// 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(gr *Group) *GroupUpdateOne {
mutation := newGroupMutation(c.config, OpUpdateOne, withGroup(gr))
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(gr *Group) *GroupDeleteOne {
return c.DeleteOneID(gr.ID)
}
// DeleteOne 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.op = OpDeleteOne
return &GroupDeleteOne{builder}
}
// Query returns a query builder for Group.
func (c *GroupClient) Query() *GroupQuery {
return &GroupQuery{
config: c.config,
}
}
// 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(gr *Group) *UserQuery {
query := &UserQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := gr.ID
step := sqlgraph.NewStep(
sqlgraph.From(group.Table, group.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2M, true, group.UsersTable, group.UsersPrimaryKey...),
)
fromV = sqlgraph.Neighbors(gr.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryJoinedUsers queries the joined_users edge of a Group.
func (c *GroupClient) QueryJoinedUsers(gr *Group) *UserGroupQuery {
query := &UserGroupQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := gr.ID
step := sqlgraph.NewStep(
sqlgraph.From(group.Table, group.FieldID, id),
sqlgraph.To(usergroup.Table, usergroup.FieldID),
sqlgraph.Edge(sqlgraph.O2M, true, group.JoinedUsersTable, group.JoinedUsersColumn),
)
fromV = sqlgraph.Neighbors(gr.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *GroupClient) Hooks() []Hook {
return c.hooks.Group
}
// RelationshipClient is a client for the Relationship schema.
type RelationshipClient struct {
config
}
// NewRelationshipClient returns a client for the Relationship from the given config.
func NewRelationshipClient(c config) *RelationshipClient {
return &RelationshipClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `relationship.Hooks(f(g(h())))`.
func (c *RelationshipClient) Use(hooks ...Hook) {
c.hooks.Relationship = append(c.hooks.Relationship, hooks...)
}
// Create returns a builder for creating a Relationship entity.
func (c *RelationshipClient) Create() *RelationshipCreate {
mutation := newRelationshipMutation(c.config, OpCreate)
return &RelationshipCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of Relationship entities.
func (c *RelationshipClient) CreateBulk(builders ...*RelationshipCreate) *RelationshipCreateBulk {
return &RelationshipCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for Relationship.
func (c *RelationshipClient) Update() *RelationshipUpdate {
mutation := newRelationshipMutation(c.config, OpUpdate)
return &RelationshipUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *RelationshipClient) UpdateOne(r *Relationship) *RelationshipUpdateOne {
mutation := newRelationshipMutation(c.config, OpUpdateOne)
mutation.user = &r.UserID
mutation.relative = &r.RelativeID
return &RelationshipUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for Relationship.
func (c *RelationshipClient) Delete() *RelationshipDelete {
mutation := newRelationshipMutation(c.config, OpDelete)
return &RelationshipDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Query returns a query builder for Relationship.
func (c *RelationshipClient) Query() *RelationshipQuery {
return &RelationshipQuery{
config: c.config,
}
}
// QueryUser queries the user edge of a Relationship.
func (c *RelationshipClient) QueryUser(r *Relationship) *UserQuery {
return c.Query().
Where(relationship.UserID(r.UserID), relationship.RelativeID(r.RelativeID)).
QueryUser()
}
// QueryRelative queries the relative edge of a Relationship.
func (c *RelationshipClient) QueryRelative(r *Relationship) *UserQuery {
return c.Query().
Where(relationship.UserID(r.UserID), relationship.RelativeID(r.RelativeID)).
QueryRelative()
}
// QueryInfo queries the info edge of a Relationship.
func (c *RelationshipClient) QueryInfo(r *Relationship) *RelationshipInfoQuery {
return c.Query().
Where(relationship.UserID(r.UserID), relationship.RelativeID(r.RelativeID)).
QueryInfo()
}
// Hooks returns the client hooks.
func (c *RelationshipClient) Hooks() []Hook {
return c.hooks.Relationship
}
// RelationshipInfoClient is a client for the RelationshipInfo schema.
type RelationshipInfoClient struct {
config
}
// NewRelationshipInfoClient returns a client for the RelationshipInfo from the given config.
func NewRelationshipInfoClient(c config) *RelationshipInfoClient {
return &RelationshipInfoClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `relationshipinfo.Hooks(f(g(h())))`.
func (c *RelationshipInfoClient) Use(hooks ...Hook) {
c.hooks.RelationshipInfo = append(c.hooks.RelationshipInfo, hooks...)
}
// Create returns a builder for creating a RelationshipInfo entity.
func (c *RelationshipInfoClient) Create() *RelationshipInfoCreate {
mutation := newRelationshipInfoMutation(c.config, OpCreate)
return &RelationshipInfoCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of RelationshipInfo entities.
func (c *RelationshipInfoClient) CreateBulk(builders ...*RelationshipInfoCreate) *RelationshipInfoCreateBulk {
return &RelationshipInfoCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for RelationshipInfo.
func (c *RelationshipInfoClient) Update() *RelationshipInfoUpdate {
mutation := newRelationshipInfoMutation(c.config, OpUpdate)
return &RelationshipInfoUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *RelationshipInfoClient) UpdateOne(ri *RelationshipInfo) *RelationshipInfoUpdateOne {
mutation := newRelationshipInfoMutation(c.config, OpUpdateOne, withRelationshipInfo(ri))
return &RelationshipInfoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *RelationshipInfoClient) UpdateOneID(id int) *RelationshipInfoUpdateOne {
mutation := newRelationshipInfoMutation(c.config, OpUpdateOne, withRelationshipInfoID(id))
return &RelationshipInfoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for RelationshipInfo.
func (c *RelationshipInfoClient) Delete() *RelationshipInfoDelete {
mutation := newRelationshipInfoMutation(c.config, OpDelete)
return &RelationshipInfoDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *RelationshipInfoClient) DeleteOne(ri *RelationshipInfo) *RelationshipInfoDeleteOne {
return c.DeleteOneID(ri.ID)
}
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *RelationshipInfoClient) DeleteOneID(id int) *RelationshipInfoDeleteOne {
builder := c.Delete().Where(relationshipinfo.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &RelationshipInfoDeleteOne{builder}
}
// Query returns a query builder for RelationshipInfo.
func (c *RelationshipInfoClient) Query() *RelationshipInfoQuery {
return &RelationshipInfoQuery{
config: c.config,
}
}
// Get returns a RelationshipInfo entity by its id.
func (c *RelationshipInfoClient) Get(ctx context.Context, id int) (*RelationshipInfo, error) {
return c.Query().Where(relationshipinfo.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *RelationshipInfoClient) GetX(ctx context.Context, id int) *RelationshipInfo {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *RelationshipInfoClient) Hooks() []Hook {
return c.hooks.RelationshipInfo
}
// RoleClient is a client for the Role schema.
type RoleClient struct {
config
}
// NewRoleClient returns a client for the Role from the given config.
func NewRoleClient(c config) *RoleClient {
return &RoleClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `role.Hooks(f(g(h())))`.
func (c *RoleClient) Use(hooks ...Hook) {
c.hooks.Role = append(c.hooks.Role, hooks...)
}
// Create returns a builder for creating a Role entity.
func (c *RoleClient) Create() *RoleCreate {
mutation := newRoleMutation(c.config, OpCreate)
return &RoleCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of Role entities.
func (c *RoleClient) CreateBulk(builders ...*RoleCreate) *RoleCreateBulk {
return &RoleCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for Role.
func (c *RoleClient) Update() *RoleUpdate {
mutation := newRoleMutation(c.config, OpUpdate)
return &RoleUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *RoleClient) UpdateOne(r *Role) *RoleUpdateOne {
mutation := newRoleMutation(c.config, OpUpdateOne, withRole(r))
return &RoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *RoleClient) UpdateOneID(id int) *RoleUpdateOne {
mutation := newRoleMutation(c.config, OpUpdateOne, withRoleID(id))
return &RoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for Role.
func (c *RoleClient) Delete() *RoleDelete {
mutation := newRoleMutation(c.config, OpDelete)
return &RoleDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *RoleClient) DeleteOne(r *Role) *RoleDeleteOne {
return c.DeleteOneID(r.ID)
}
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *RoleClient) DeleteOneID(id int) *RoleDeleteOne {
builder := c.Delete().Where(role.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &RoleDeleteOne{builder}
}
// Query returns a query builder for Role.
func (c *RoleClient) Query() *RoleQuery {
return &RoleQuery{
config: c.config,
}
}
// Get returns a Role entity by its id.
func (c *RoleClient) Get(ctx context.Context, id int) (*Role, error) {
return c.Query().Where(role.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *RoleClient) GetX(ctx context.Context, id int) *Role {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryUser queries the user edge of a Role.
func (c *RoleClient) QueryUser(r *Role) *UserQuery {
query := &UserQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := r.ID
step := sqlgraph.NewStep(
sqlgraph.From(role.Table, role.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2M, true, role.UserTable, role.UserPrimaryKey...),
)
fromV = sqlgraph.Neighbors(r.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryRolesUsers queries the roles_users edge of a Role.
func (c *RoleClient) QueryRolesUsers(r *Role) *RoleUserQuery {
query := &RoleUserQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := r.ID
step := sqlgraph.NewStep(
sqlgraph.From(role.Table, role.FieldID, id),
sqlgraph.To(roleuser.Table, roleuser.RoleColumn),
sqlgraph.Edge(sqlgraph.O2M, true, role.RolesUsersTable, role.RolesUsersColumn),
)
fromV = sqlgraph.Neighbors(r.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *RoleClient) Hooks() []Hook {
return c.hooks.Role
}
// RoleUserClient is a client for the RoleUser schema.
type RoleUserClient struct {
config
}
// NewRoleUserClient returns a client for the RoleUser from the given config.
func NewRoleUserClient(c config) *RoleUserClient {
return &RoleUserClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `roleuser.Hooks(f(g(h())))`.
func (c *RoleUserClient) Use(hooks ...Hook) {
c.hooks.RoleUser = append(c.hooks.RoleUser, hooks...)
}
// Create returns a builder for creating a RoleUser entity.
func (c *RoleUserClient) Create() *RoleUserCreate {
mutation := newRoleUserMutation(c.config, OpCreate)
return &RoleUserCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of RoleUser entities.
func (c *RoleUserClient) CreateBulk(builders ...*RoleUserCreate) *RoleUserCreateBulk {
return &RoleUserCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for RoleUser.
func (c *RoleUserClient) Update() *RoleUserUpdate {
mutation := newRoleUserMutation(c.config, OpUpdate)
return &RoleUserUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *RoleUserClient) UpdateOne(ru *RoleUser) *RoleUserUpdateOne {
mutation := newRoleUserMutation(c.config, OpUpdateOne)
mutation.user = &ru.UserID
mutation.role = &ru.RoleID
return &RoleUserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for RoleUser.
func (c *RoleUserClient) Delete() *RoleUserDelete {
mutation := newRoleUserMutation(c.config, OpDelete)
return &RoleUserDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Query returns a query builder for RoleUser.
func (c *RoleUserClient) Query() *RoleUserQuery {
return &RoleUserQuery{
config: c.config,
}
}
// QueryRole queries the role edge of a RoleUser.
func (c *RoleUserClient) QueryRole(ru *RoleUser) *RoleQuery {
return c.Query().
Where(roleuser.UserID(ru.UserID), roleuser.RoleID(ru.RoleID)).
QueryRole()
}
// QueryUser queries the user edge of a RoleUser.
func (c *RoleUserClient) QueryUser(ru *RoleUser) *UserQuery {
return c.Query().
Where(roleuser.UserID(ru.UserID), roleuser.RoleID(ru.RoleID)).
QueryUser()
}
// Hooks returns the client hooks.
func (c *RoleUserClient) Hooks() []Hook {
return c.hooks.RoleUser
}
// TagClient is a client for the Tag schema.
type TagClient struct {
config
}
// NewTagClient returns a client for the Tag from the given config.
func NewTagClient(c config) *TagClient {
return &TagClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `tag.Hooks(f(g(h())))`.
func (c *TagClient) Use(hooks ...Hook) {
c.hooks.Tag = append(c.hooks.Tag, hooks...)
}
// Create returns a builder for creating a Tag entity.
func (c *TagClient) Create() *TagCreate {
mutation := newTagMutation(c.config, OpCreate)
return &TagCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of Tag entities.
func (c *TagClient) CreateBulk(builders ...*TagCreate) *TagCreateBulk {
return &TagCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for Tag.
func (c *TagClient) Update() *TagUpdate {
mutation := newTagMutation(c.config, OpUpdate)
return &TagUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *TagClient) UpdateOne(t *Tag) *TagUpdateOne {
mutation := newTagMutation(c.config, OpUpdateOne, withTag(t))
return &TagUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *TagClient) UpdateOneID(id int) *TagUpdateOne {
mutation := newTagMutation(c.config, OpUpdateOne, withTagID(id))
return &TagUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for Tag.
func (c *TagClient) Delete() *TagDelete {
mutation := newTagMutation(c.config, OpDelete)
return &TagDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *TagClient) DeleteOne(t *Tag) *TagDeleteOne {
return c.DeleteOneID(t.ID)
}
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *TagClient) DeleteOneID(id int) *TagDeleteOne {
builder := c.Delete().Where(tag.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &TagDeleteOne{builder}
}
// Query returns a query builder for Tag.
func (c *TagClient) Query() *TagQuery {
return &TagQuery{
config: c.config,
}
}
// Get returns a Tag entity by its id.
func (c *TagClient) Get(ctx context.Context, id int) (*Tag, error) {
return c.Query().Where(tag.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *TagClient) GetX(ctx context.Context, id int) *Tag {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryTweets queries the tweets edge of a Tag.
func (c *TagClient) QueryTweets(t *Tag) *TweetQuery {
query := &TweetQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := t.ID
step := sqlgraph.NewStep(
sqlgraph.From(tag.Table, tag.FieldID, id),
sqlgraph.To(tweet.Table, tweet.FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, tag.TweetsTable, tag.TweetsPrimaryKey...),
)
fromV = sqlgraph.Neighbors(t.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryTweetTags queries the tweet_tags edge of a Tag.
func (c *TagClient) QueryTweetTags(t *Tag) *TweetTagQuery {
query := &TweetTagQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := t.ID
step := sqlgraph.NewStep(
sqlgraph.From(tag.Table, tag.FieldID, id),
sqlgraph.To(tweettag.Table, tweettag.FieldID),
sqlgraph.Edge(sqlgraph.O2M, true, tag.TweetTagsTable, tag.TweetTagsColumn),
)
fromV = sqlgraph.Neighbors(t.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *TagClient) Hooks() []Hook {
return c.hooks.Tag
}
// TweetClient is a client for the Tweet schema.
type TweetClient struct {
config
}
// NewTweetClient returns a client for the Tweet from the given config.
func NewTweetClient(c config) *TweetClient {
return &TweetClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `tweet.Hooks(f(g(h())))`.
func (c *TweetClient) Use(hooks ...Hook) {
c.hooks.Tweet = append(c.hooks.Tweet, hooks...)
}
// Create returns a builder for creating a Tweet entity.
func (c *TweetClient) Create() *TweetCreate {
mutation := newTweetMutation(c.config, OpCreate)
return &TweetCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of Tweet entities.
func (c *TweetClient) CreateBulk(builders ...*TweetCreate) *TweetCreateBulk {
return &TweetCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for Tweet.
func (c *TweetClient) Update() *TweetUpdate {
mutation := newTweetMutation(c.config, OpUpdate)
return &TweetUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *TweetClient) UpdateOne(t *Tweet) *TweetUpdateOne {
mutation := newTweetMutation(c.config, OpUpdateOne, withTweet(t))
return &TweetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *TweetClient) UpdateOneID(id int) *TweetUpdateOne {
mutation := newTweetMutation(c.config, OpUpdateOne, withTweetID(id))
return &TweetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for Tweet.
func (c *TweetClient) Delete() *TweetDelete {
mutation := newTweetMutation(c.config, OpDelete)
return &TweetDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *TweetClient) DeleteOne(t *Tweet) *TweetDeleteOne {
return c.DeleteOneID(t.ID)
}
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *TweetClient) DeleteOneID(id int) *TweetDeleteOne {
builder := c.Delete().Where(tweet.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &TweetDeleteOne{builder}
}
// Query returns a query builder for Tweet.
func (c *TweetClient) Query() *TweetQuery {
return &TweetQuery{
config: c.config,
}
}
// Get returns a Tweet entity by its id.
func (c *TweetClient) Get(ctx context.Context, id int) (*Tweet, error) {
return c.Query().Where(tweet.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *TweetClient) GetX(ctx context.Context, id int) *Tweet {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryLikedUsers queries the liked_users edge of a Tweet.
func (c *TweetClient) QueryLikedUsers(t *Tweet) *UserQuery {
query := &UserQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := t.ID
step := sqlgraph.NewStep(
sqlgraph.From(tweet.Table, tweet.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2M, true, tweet.LikedUsersTable, tweet.LikedUsersPrimaryKey...),
)
fromV = sqlgraph.Neighbors(t.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryUser queries the user edge of a Tweet.
func (c *TweetClient) QueryUser(t *Tweet) *UserQuery {
query := &UserQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := t.ID
step := sqlgraph.NewStep(
sqlgraph.From(tweet.Table, tweet.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2M, true, tweet.UserTable, tweet.UserPrimaryKey...),
)
fromV = sqlgraph.Neighbors(t.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryTags queries the tags edge of a Tweet.
func (c *TweetClient) QueryTags(t *Tweet) *TagQuery {
query := &TagQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := t.ID
step := sqlgraph.NewStep(
sqlgraph.From(tweet.Table, tweet.FieldID, id),
sqlgraph.To(tag.Table, tag.FieldID),
sqlgraph.Edge(sqlgraph.M2M, true, tweet.TagsTable, tweet.TagsPrimaryKey...),
)
fromV = sqlgraph.Neighbors(t.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryLikes queries the likes edge of a Tweet.
func (c *TweetClient) QueryLikes(t *Tweet) *TweetLikeQuery {
query := &TweetLikeQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := t.ID
step := sqlgraph.NewStep(
sqlgraph.From(tweet.Table, tweet.FieldID, id),
sqlgraph.To(tweetlike.Table, tweetlike.TweetColumn),
sqlgraph.Edge(sqlgraph.O2M, true, tweet.LikesTable, tweet.LikesColumn),
)
fromV = sqlgraph.Neighbors(t.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryTweetUser queries the tweet_user edge of a Tweet.
func (c *TweetClient) QueryTweetUser(t *Tweet) *UserTweetQuery {
query := &UserTweetQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := t.ID
step := sqlgraph.NewStep(
sqlgraph.From(tweet.Table, tweet.FieldID, id),
sqlgraph.To(usertweet.Table, usertweet.FieldID),
sqlgraph.Edge(sqlgraph.O2M, true, tweet.TweetUserTable, tweet.TweetUserColumn),
)
fromV = sqlgraph.Neighbors(t.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryTweetTags queries the tweet_tags edge of a Tweet.
func (c *TweetClient) QueryTweetTags(t *Tweet) *TweetTagQuery {
query := &TweetTagQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := t.ID
step := sqlgraph.NewStep(
sqlgraph.From(tweet.Table, tweet.FieldID, id),
sqlgraph.To(tweettag.Table, tweettag.FieldID),
sqlgraph.Edge(sqlgraph.O2M, true, tweet.TweetTagsTable, tweet.TweetTagsColumn),
)
fromV = sqlgraph.Neighbors(t.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *TweetClient) Hooks() []Hook {
return c.hooks.Tweet
}
// TweetLikeClient is a client for the TweetLike schema.
type TweetLikeClient struct {
config
}
// NewTweetLikeClient returns a client for the TweetLike from the given config.
func NewTweetLikeClient(c config) *TweetLikeClient {
return &TweetLikeClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `tweetlike.Hooks(f(g(h())))`.
func (c *TweetLikeClient) Use(hooks ...Hook) {
c.hooks.TweetLike = append(c.hooks.TweetLike, hooks...)
}
// Create returns a builder for creating a TweetLike entity.
func (c *TweetLikeClient) Create() *TweetLikeCreate {
mutation := newTweetLikeMutation(c.config, OpCreate)
return &TweetLikeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of TweetLike entities.
func (c *TweetLikeClient) CreateBulk(builders ...*TweetLikeCreate) *TweetLikeCreateBulk {
return &TweetLikeCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for TweetLike.
func (c *TweetLikeClient) Update() *TweetLikeUpdate {
mutation := newTweetLikeMutation(c.config, OpUpdate)
return &TweetLikeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *TweetLikeClient) UpdateOne(tl *TweetLike) *TweetLikeUpdateOne {
mutation := newTweetLikeMutation(c.config, OpUpdateOne)
mutation.user = &tl.UserID
mutation.tweet = &tl.TweetID
return &TweetLikeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for TweetLike.
func (c *TweetLikeClient) Delete() *TweetLikeDelete {
mutation := newTweetLikeMutation(c.config, OpDelete)
return &TweetLikeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Query returns a query builder for TweetLike.
func (c *TweetLikeClient) Query() *TweetLikeQuery {
return &TweetLikeQuery{
config: c.config,
}
}
// QueryTweet queries the tweet edge of a TweetLike.
func (c *TweetLikeClient) QueryTweet(tl *TweetLike) *TweetQuery {
return c.Query().
Where(tweetlike.UserID(tl.UserID), tweetlike.TweetID(tl.TweetID)).
QueryTweet()
}
// QueryUser queries the user edge of a TweetLike.
func (c *TweetLikeClient) QueryUser(tl *TweetLike) *UserQuery {
return c.Query().
Where(tweetlike.UserID(tl.UserID), tweetlike.TweetID(tl.TweetID)).
QueryUser()
}
// Hooks returns the client hooks.
func (c *TweetLikeClient) Hooks() []Hook {
hooks := c.hooks.TweetLike
return append(hooks[:len(hooks):len(hooks)], tweetlike.Hooks[:]...)
}
// TweetTagClient is a client for the TweetTag schema.
type TweetTagClient struct {
config
}
// NewTweetTagClient returns a client for the TweetTag from the given config.
func NewTweetTagClient(c config) *TweetTagClient {
return &TweetTagClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `tweettag.Hooks(f(g(h())))`.
func (c *TweetTagClient) Use(hooks ...Hook) {
c.hooks.TweetTag = append(c.hooks.TweetTag, hooks...)
}
// Create returns a builder for creating a TweetTag entity.
func (c *TweetTagClient) Create() *TweetTagCreate {
mutation := newTweetTagMutation(c.config, OpCreate)
return &TweetTagCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of TweetTag entities.
func (c *TweetTagClient) CreateBulk(builders ...*TweetTagCreate) *TweetTagCreateBulk {
return &TweetTagCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for TweetTag.
func (c *TweetTagClient) Update() *TweetTagUpdate {
mutation := newTweetTagMutation(c.config, OpUpdate)
return &TweetTagUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *TweetTagClient) UpdateOne(tt *TweetTag) *TweetTagUpdateOne {
mutation := newTweetTagMutation(c.config, OpUpdateOne, withTweetTag(tt))
return &TweetTagUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *TweetTagClient) UpdateOneID(id uuid.UUID) *TweetTagUpdateOne {
mutation := newTweetTagMutation(c.config, OpUpdateOne, withTweetTagID(id))
return &TweetTagUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for TweetTag.
func (c *TweetTagClient) Delete() *TweetTagDelete {
mutation := newTweetTagMutation(c.config, OpDelete)
return &TweetTagDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *TweetTagClient) DeleteOne(tt *TweetTag) *TweetTagDeleteOne {
return c.DeleteOneID(tt.ID)
}
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *TweetTagClient) DeleteOneID(id uuid.UUID) *TweetTagDeleteOne {
builder := c.Delete().Where(tweettag.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &TweetTagDeleteOne{builder}
}
// Query returns a query builder for TweetTag.
func (c *TweetTagClient) Query() *TweetTagQuery {
return &TweetTagQuery{
config: c.config,
}
}
// Get returns a TweetTag entity by its id.
func (c *TweetTagClient) Get(ctx context.Context, id uuid.UUID) (*TweetTag, error) {
return c.Query().Where(tweettag.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *TweetTagClient) GetX(ctx context.Context, id uuid.UUID) *TweetTag {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryTag queries the tag edge of a TweetTag.
func (c *TweetTagClient) QueryTag(tt *TweetTag) *TagQuery {
query := &TagQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := tt.ID
step := sqlgraph.NewStep(
sqlgraph.From(tweettag.Table, tweettag.FieldID, id),
sqlgraph.To(tag.Table, tag.FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, tweettag.TagTable, tweettag.TagColumn),
)
fromV = sqlgraph.Neighbors(tt.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryTweet queries the tweet edge of a TweetTag.
func (c *TweetTagClient) QueryTweet(tt *TweetTag) *TweetQuery {
query := &TweetQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := tt.ID
step := sqlgraph.NewStep(
sqlgraph.From(tweettag.Table, tweettag.FieldID, id),
sqlgraph.To(tweet.Table, tweet.FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, tweettag.TweetTable, tweettag.TweetColumn),
)
fromV = sqlgraph.Neighbors(tt.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *TweetTagClient) Hooks() []Hook {
return c.hooks.TweetTag
}
// 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
}
// QueryGroups queries the groups edge of a User.
func (c *UserClient) QueryGroups(u *User) *GroupQuery {
query := &GroupQuery{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(group.Table, group.FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, user.GroupsTable, user.GroupsPrimaryKey...),
)
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryFriends queries the friends edge of a User.
func (c *UserClient) QueryFriends(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.M2M, false, user.FriendsTable, user.FriendsPrimaryKey...),
)
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryRelatives queries the relatives edge of a User.
func (c *UserClient) QueryRelatives(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.M2M, false, user.RelativesTable, user.RelativesPrimaryKey...),
)
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryLikedTweets queries the liked_tweets edge of a User.
func (c *UserClient) QueryLikedTweets(u *User) *TweetQuery {
query := &TweetQuery{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(tweet.Table, tweet.FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, user.LikedTweetsTable, user.LikedTweetsPrimaryKey...),
)
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryTweets queries the tweets edge of a User.
func (c *UserClient) QueryTweets(u *User) *TweetQuery {
query := &TweetQuery{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(tweet.Table, tweet.FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, user.TweetsTable, user.TweetsPrimaryKey...),
)
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryRoles queries the roles edge of a User.
func (c *UserClient) QueryRoles(u *User) *RoleQuery {
query := &RoleQuery{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(role.Table, role.FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, user.RolesTable, user.RolesPrimaryKey...),
)
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryJoinedGroups queries the joined_groups edge of a User.
func (c *UserClient) QueryJoinedGroups(u *User) *UserGroupQuery {
query := &UserGroupQuery{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(usergroup.Table, usergroup.FieldID),
sqlgraph.Edge(sqlgraph.O2M, true, user.JoinedGroupsTable, user.JoinedGroupsColumn),
)
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryFriendships queries the friendships edge of a User.
func (c *UserClient) QueryFriendships(u *User) *FriendshipQuery {
query := &FriendshipQuery{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(friendship.Table, friendship.FieldID),
sqlgraph.Edge(sqlgraph.O2M, true, user.FriendshipsTable, user.FriendshipsColumn),
)
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryRelationship queries the relationship edge of a User.
func (c *UserClient) QueryRelationship(u *User) *RelationshipQuery {
query := &RelationshipQuery{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(relationship.Table, relationship.UserColumn),
sqlgraph.Edge(sqlgraph.O2M, true, user.RelationshipTable, user.RelationshipColumn),
)
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryLikes queries the likes edge of a User.
func (c *UserClient) QueryLikes(u *User) *TweetLikeQuery {
query := &TweetLikeQuery{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(tweetlike.Table, tweetlike.UserColumn),
sqlgraph.Edge(sqlgraph.O2M, true, user.LikesTable, user.LikesColumn),
)
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryUserTweets queries the user_tweets edge of a User.
func (c *UserClient) QueryUserTweets(u *User) *UserTweetQuery {
query := &UserTweetQuery{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(usertweet.Table, usertweet.FieldID),
sqlgraph.Edge(sqlgraph.O2M, true, user.UserTweetsTable, user.UserTweetsColumn),
)
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryRolesUsers queries the roles_users edge of a User.
func (c *UserClient) QueryRolesUsers(u *User) *RoleUserQuery {
query := &RoleUserQuery{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(roleuser.Table, roleuser.UserColumn),
sqlgraph.Edge(sqlgraph.O2M, true, user.RolesUsersTable, user.RolesUsersColumn),
)
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *UserClient) Hooks() []Hook {
hooks := c.hooks.User
return append(hooks[:len(hooks):len(hooks)], user.Hooks[:]...)
}
// UserGroupClient is a client for the UserGroup schema.
type UserGroupClient struct {
config
}
// NewUserGroupClient returns a client for the UserGroup from the given config.
func NewUserGroupClient(c config) *UserGroupClient {
return &UserGroupClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `usergroup.Hooks(f(g(h())))`.
func (c *UserGroupClient) Use(hooks ...Hook) {
c.hooks.UserGroup = append(c.hooks.UserGroup, hooks...)
}
// Create returns a builder for creating a UserGroup entity.
func (c *UserGroupClient) Create() *UserGroupCreate {
mutation := newUserGroupMutation(c.config, OpCreate)
return &UserGroupCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of UserGroup entities.
func (c *UserGroupClient) CreateBulk(builders ...*UserGroupCreate) *UserGroupCreateBulk {
return &UserGroupCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for UserGroup.
func (c *UserGroupClient) Update() *UserGroupUpdate {
mutation := newUserGroupMutation(c.config, OpUpdate)
return &UserGroupUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *UserGroupClient) UpdateOne(ug *UserGroup) *UserGroupUpdateOne {
mutation := newUserGroupMutation(c.config, OpUpdateOne, withUserGroup(ug))
return &UserGroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *UserGroupClient) UpdateOneID(id int) *UserGroupUpdateOne {
mutation := newUserGroupMutation(c.config, OpUpdateOne, withUserGroupID(id))
return &UserGroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for UserGroup.
func (c *UserGroupClient) Delete() *UserGroupDelete {
mutation := newUserGroupMutation(c.config, OpDelete)
return &UserGroupDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *UserGroupClient) DeleteOne(ug *UserGroup) *UserGroupDeleteOne {
return c.DeleteOneID(ug.ID)
}
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *UserGroupClient) DeleteOneID(id int) *UserGroupDeleteOne {
builder := c.Delete().Where(usergroup.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &UserGroupDeleteOne{builder}
}
// Query returns a query builder for UserGroup.
func (c *UserGroupClient) Query() *UserGroupQuery {
return &UserGroupQuery{
config: c.config,
}
}
// Get returns a UserGroup entity by its id.
func (c *UserGroupClient) Get(ctx context.Context, id int) (*UserGroup, error) {
return c.Query().Where(usergroup.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *UserGroupClient) GetX(ctx context.Context, id int) *UserGroup {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryUser queries the user edge of a UserGroup.
func (c *UserGroupClient) QueryUser(ug *UserGroup) *UserQuery {
query := &UserQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := ug.ID
step := sqlgraph.NewStep(
sqlgraph.From(usergroup.Table, usergroup.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, usergroup.UserTable, usergroup.UserColumn),
)
fromV = sqlgraph.Neighbors(ug.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryGroup queries the group edge of a UserGroup.
func (c *UserGroupClient) QueryGroup(ug *UserGroup) *GroupQuery {
query := &GroupQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := ug.ID
step := sqlgraph.NewStep(
sqlgraph.From(usergroup.Table, usergroup.FieldID, id),
sqlgraph.To(group.Table, group.FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, usergroup.GroupTable, usergroup.GroupColumn),
)
fromV = sqlgraph.Neighbors(ug.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *UserGroupClient) Hooks() []Hook {
return c.hooks.UserGroup
}
// UserTweetClient is a client for the UserTweet schema.
type UserTweetClient struct {
config
}
// NewUserTweetClient returns a client for the UserTweet from the given config.
func NewUserTweetClient(c config) *UserTweetClient {
return &UserTweetClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `usertweet.Hooks(f(g(h())))`.
func (c *UserTweetClient) Use(hooks ...Hook) {
c.hooks.UserTweet = append(c.hooks.UserTweet, hooks...)
}
// Create returns a builder for creating a UserTweet entity.
func (c *UserTweetClient) Create() *UserTweetCreate {
mutation := newUserTweetMutation(c.config, OpCreate)
return &UserTweetCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of UserTweet entities.
func (c *UserTweetClient) CreateBulk(builders ...*UserTweetCreate) *UserTweetCreateBulk {
return &UserTweetCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for UserTweet.
func (c *UserTweetClient) Update() *UserTweetUpdate {
mutation := newUserTweetMutation(c.config, OpUpdate)
return &UserTweetUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *UserTweetClient) UpdateOne(ut *UserTweet) *UserTweetUpdateOne {
mutation := newUserTweetMutation(c.config, OpUpdateOne, withUserTweet(ut))
return &UserTweetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *UserTweetClient) UpdateOneID(id int) *UserTweetUpdateOne {
mutation := newUserTweetMutation(c.config, OpUpdateOne, withUserTweetID(id))
return &UserTweetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for UserTweet.
func (c *UserTweetClient) Delete() *UserTweetDelete {
mutation := newUserTweetMutation(c.config, OpDelete)
return &UserTweetDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *UserTweetClient) DeleteOne(ut *UserTweet) *UserTweetDeleteOne {
return c.DeleteOneID(ut.ID)
}
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *UserTweetClient) DeleteOneID(id int) *UserTweetDeleteOne {
builder := c.Delete().Where(usertweet.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &UserTweetDeleteOne{builder}
}
// Query returns a query builder for UserTweet.
func (c *UserTweetClient) Query() *UserTweetQuery {
return &UserTweetQuery{
config: c.config,
}
}
// Get returns a UserTweet entity by its id.
func (c *UserTweetClient) Get(ctx context.Context, id int) (*UserTweet, error) {
return c.Query().Where(usertweet.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *UserTweetClient) GetX(ctx context.Context, id int) *UserTweet {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryUser queries the user edge of a UserTweet.
func (c *UserTweetClient) QueryUser(ut *UserTweet) *UserQuery {
query := &UserQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := ut.ID
step := sqlgraph.NewStep(
sqlgraph.From(usertweet.Table, usertweet.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, usertweet.UserTable, usertweet.UserColumn),
)
fromV = sqlgraph.Neighbors(ut.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryTweet queries the tweet edge of a UserTweet.
func (c *UserTweetClient) QueryTweet(ut *UserTweet) *TweetQuery {
query := &TweetQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := ut.ID
step := sqlgraph.NewStep(
sqlgraph.From(usertweet.Table, usertweet.FieldID, id),
sqlgraph.To(tweet.Table, tweet.FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, usertweet.TweetTable, usertweet.TweetColumn),
)
fromV = sqlgraph.Neighbors(ut.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *UserTweetClient) Hooks() []Hook {
return c.hooks.UserTweet
}
|