mutation.go
1 // Code generated by ent, DO NOT EDIT. 2 3 package ent 4 5 import ( 6 "context" 7 "errors" 8 "fmt" 9 "sync" 10 "time" 11 12 "entgo.io/ent" 13 "entgo.io/ent/dialect/sql" 14 "github.com/google/uuid" 15 "github.com/mrusme/journalist/ent/feed" 16 "github.com/mrusme/journalist/ent/item" 17 "github.com/mrusme/journalist/ent/predicate" 18 "github.com/mrusme/journalist/ent/read" 19 "github.com/mrusme/journalist/ent/subscription" 20 "github.com/mrusme/journalist/ent/token" 21 "github.com/mrusme/journalist/ent/user" 22 ) 23 24 const ( 25 // Operation types. 26 OpCreate = ent.OpCreate 27 OpDelete = ent.OpDelete 28 OpDeleteOne = ent.OpDeleteOne 29 OpUpdate = ent.OpUpdate 30 OpUpdateOne = ent.OpUpdateOne 31 32 // Node types. 33 TypeFeed = "Feed" 34 TypeItem = "Item" 35 TypeRead = "Read" 36 TypeSubscription = "Subscription" 37 TypeToken = "Token" 38 TypeUser = "User" 39 ) 40 41 // FeedMutation represents an operation that mutates the Feed nodes in the graph. 42 type FeedMutation struct { 43 config 44 op Op 45 typ string 46 id *uuid.UUID 47 url *string 48 username *string 49 password *string 50 feed_title *string 51 feed_description *string 52 feed_link *string 53 feed_feed_link *string 54 feed_updated *time.Time 55 feed_published *time.Time 56 feed_author_name *string 57 feed_author_email *string 58 feed_language *string 59 feed_image_title *string 60 feed_image_url *string 61 feed_copyright *string 62 feed_generator *string 63 feed_categories *string 64 created_at *time.Time 65 updated_at *time.Time 66 deleted_at *time.Time 67 clearedFields map[string]struct{} 68 items map[uuid.UUID]struct{} 69 removeditems map[uuid.UUID]struct{} 70 cleareditems bool 71 subscribed_users map[uuid.UUID]struct{} 72 removedsubscribed_users map[uuid.UUID]struct{} 73 clearedsubscribed_users bool 74 subscriptions map[uuid.UUID]struct{} 75 removedsubscriptions map[uuid.UUID]struct{} 76 clearedsubscriptions bool 77 done bool 78 oldValue func(context.Context) (*Feed, error) 79 predicates []predicate.Feed 80 } 81 82 var _ ent.Mutation = (*FeedMutation)(nil) 83 84 // feedOption allows management of the mutation configuration using functional options. 85 type feedOption func(*FeedMutation) 86 87 // newFeedMutation creates new mutation for the Feed entity. 88 func newFeedMutation(c config, op Op, opts ...feedOption) *FeedMutation { 89 m := &FeedMutation{ 90 config: c, 91 op: op, 92 typ: TypeFeed, 93 clearedFields: make(map[string]struct{}), 94 } 95 for _, opt := range opts { 96 opt(m) 97 } 98 return m 99 } 100 101 // withFeedID sets the ID field of the mutation. 102 func withFeedID(id uuid.UUID) feedOption { 103 return func(m *FeedMutation) { 104 var ( 105 err error 106 once sync.Once 107 value *Feed 108 ) 109 m.oldValue = func(ctx context.Context) (*Feed, error) { 110 once.Do(func() { 111 if m.done { 112 err = errors.New("querying old values post mutation is not allowed") 113 } else { 114 value, err = m.Client().Feed.Get(ctx, id) 115 } 116 }) 117 return value, err 118 } 119 m.id = &id 120 } 121 } 122 123 // withFeed sets the old Feed of the mutation. 124 func withFeed(node *Feed) feedOption { 125 return func(m *FeedMutation) { 126 m.oldValue = func(context.Context) (*Feed, error) { 127 return node, nil 128 } 129 m.id = &node.ID 130 } 131 } 132 133 // Client returns a new `ent.Client` from the mutation. If the mutation was 134 // executed in a transaction (ent.Tx), a transactional client is returned. 135 func (m FeedMutation) Client() *Client { 136 client := &Client{config: m.config} 137 client.init() 138 return client 139 } 140 141 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 142 // it returns an error otherwise. 143 func (m FeedMutation) Tx() (*Tx, error) { 144 if _, ok := m.driver.(*txDriver); !ok { 145 return nil, errors.New("ent: mutation is not running in a transaction") 146 } 147 tx := &Tx{config: m.config} 148 tx.init() 149 return tx, nil 150 } 151 152 // SetID sets the value of the id field. Note that this 153 // operation is only accepted on creation of Feed entities. 154 func (m *FeedMutation) SetID(id uuid.UUID) { 155 m.id = &id 156 } 157 158 // ID returns the ID value in the mutation. Note that the ID is only available 159 // if it was provided to the builder or after it was returned from the database. 160 func (m *FeedMutation) ID() (id uuid.UUID, exists bool) { 161 if m.id == nil { 162 return 163 } 164 return *m.id, true 165 } 166 167 // IDs queries the database and returns the entity ids that match the mutation's predicate. 168 // That means, if the mutation is applied within a transaction with an isolation level such 169 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 170 // or updated by the mutation. 171 func (m *FeedMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { 172 switch { 173 case m.op.Is(OpUpdateOne | OpDeleteOne): 174 id, exists := m.ID() 175 if exists { 176 return []uuid.UUID{id}, nil 177 } 178 fallthrough 179 case m.op.Is(OpUpdate | OpDelete): 180 return m.Client().Feed.Query().Where(m.predicates...).IDs(ctx) 181 default: 182 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 183 } 184 } 185 186 // SetURL sets the "url" field. 187 func (m *FeedMutation) SetURL(s string) { 188 m.url = &s 189 } 190 191 // URL returns the value of the "url" field in the mutation. 192 func (m *FeedMutation) URL() (r string, exists bool) { 193 v := m.url 194 if v == nil { 195 return 196 } 197 return *v, true 198 } 199 200 // OldURL returns the old "url" field's value of the Feed entity. 201 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 202 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 203 func (m *FeedMutation) OldURL(ctx context.Context) (v string, err error) { 204 if !m.op.Is(OpUpdateOne) { 205 return v, errors.New("OldURL is only allowed on UpdateOne operations") 206 } 207 if m.id == nil || m.oldValue == nil { 208 return v, errors.New("OldURL requires an ID field in the mutation") 209 } 210 oldValue, err := m.oldValue(ctx) 211 if err != nil { 212 return v, fmt.Errorf("querying old value for OldURL: %w", err) 213 } 214 return oldValue.URL, nil 215 } 216 217 // ResetURL resets all changes to the "url" field. 218 func (m *FeedMutation) ResetURL() { 219 m.url = nil 220 } 221 222 // SetUsername sets the "username" field. 223 func (m *FeedMutation) SetUsername(s string) { 224 m.username = &s 225 } 226 227 // Username returns the value of the "username" field in the mutation. 228 func (m *FeedMutation) Username() (r string, exists bool) { 229 v := m.username 230 if v == nil { 231 return 232 } 233 return *v, true 234 } 235 236 // OldUsername returns the old "username" field's value of the Feed entity. 237 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 238 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 239 func (m *FeedMutation) OldUsername(ctx context.Context) (v string, err error) { 240 if !m.op.Is(OpUpdateOne) { 241 return v, errors.New("OldUsername is only allowed on UpdateOne operations") 242 } 243 if m.id == nil || m.oldValue == nil { 244 return v, errors.New("OldUsername requires an ID field in the mutation") 245 } 246 oldValue, err := m.oldValue(ctx) 247 if err != nil { 248 return v, fmt.Errorf("querying old value for OldUsername: %w", err) 249 } 250 return oldValue.Username, nil 251 } 252 253 // ResetUsername resets all changes to the "username" field. 254 func (m *FeedMutation) ResetUsername() { 255 m.username = nil 256 } 257 258 // SetPassword sets the "password" field. 259 func (m *FeedMutation) SetPassword(s string) { 260 m.password = &s 261 } 262 263 // Password returns the value of the "password" field in the mutation. 264 func (m *FeedMutation) Password() (r string, exists bool) { 265 v := m.password 266 if v == nil { 267 return 268 } 269 return *v, true 270 } 271 272 // OldPassword returns the old "password" field's value of the Feed entity. 273 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 274 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 275 func (m *FeedMutation) OldPassword(ctx context.Context) (v string, err error) { 276 if !m.op.Is(OpUpdateOne) { 277 return v, errors.New("OldPassword is only allowed on UpdateOne operations") 278 } 279 if m.id == nil || m.oldValue == nil { 280 return v, errors.New("OldPassword requires an ID field in the mutation") 281 } 282 oldValue, err := m.oldValue(ctx) 283 if err != nil { 284 return v, fmt.Errorf("querying old value for OldPassword: %w", err) 285 } 286 return oldValue.Password, nil 287 } 288 289 // ResetPassword resets all changes to the "password" field. 290 func (m *FeedMutation) ResetPassword() { 291 m.password = nil 292 } 293 294 // SetFeedTitle sets the "feed_title" field. 295 func (m *FeedMutation) SetFeedTitle(s string) { 296 m.feed_title = &s 297 } 298 299 // FeedTitle returns the value of the "feed_title" field in the mutation. 300 func (m *FeedMutation) FeedTitle() (r string, exists bool) { 301 v := m.feed_title 302 if v == nil { 303 return 304 } 305 return *v, true 306 } 307 308 // OldFeedTitle returns the old "feed_title" field's value of the Feed entity. 309 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 310 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 311 func (m *FeedMutation) OldFeedTitle(ctx context.Context) (v string, err error) { 312 if !m.op.Is(OpUpdateOne) { 313 return v, errors.New("OldFeedTitle is only allowed on UpdateOne operations") 314 } 315 if m.id == nil || m.oldValue == nil { 316 return v, errors.New("OldFeedTitle requires an ID field in the mutation") 317 } 318 oldValue, err := m.oldValue(ctx) 319 if err != nil { 320 return v, fmt.Errorf("querying old value for OldFeedTitle: %w", err) 321 } 322 return oldValue.FeedTitle, nil 323 } 324 325 // ResetFeedTitle resets all changes to the "feed_title" field. 326 func (m *FeedMutation) ResetFeedTitle() { 327 m.feed_title = nil 328 } 329 330 // SetFeedDescription sets the "feed_description" field. 331 func (m *FeedMutation) SetFeedDescription(s string) { 332 m.feed_description = &s 333 } 334 335 // FeedDescription returns the value of the "feed_description" field in the mutation. 336 func (m *FeedMutation) FeedDescription() (r string, exists bool) { 337 v := m.feed_description 338 if v == nil { 339 return 340 } 341 return *v, true 342 } 343 344 // OldFeedDescription returns the old "feed_description" field's value of the Feed entity. 345 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 346 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 347 func (m *FeedMutation) OldFeedDescription(ctx context.Context) (v string, err error) { 348 if !m.op.Is(OpUpdateOne) { 349 return v, errors.New("OldFeedDescription is only allowed on UpdateOne operations") 350 } 351 if m.id == nil || m.oldValue == nil { 352 return v, errors.New("OldFeedDescription requires an ID field in the mutation") 353 } 354 oldValue, err := m.oldValue(ctx) 355 if err != nil { 356 return v, fmt.Errorf("querying old value for OldFeedDescription: %w", err) 357 } 358 return oldValue.FeedDescription, nil 359 } 360 361 // ResetFeedDescription resets all changes to the "feed_description" field. 362 func (m *FeedMutation) ResetFeedDescription() { 363 m.feed_description = nil 364 } 365 366 // SetFeedLink sets the "feed_link" field. 367 func (m *FeedMutation) SetFeedLink(s string) { 368 m.feed_link = &s 369 } 370 371 // FeedLink returns the value of the "feed_link" field in the mutation. 372 func (m *FeedMutation) FeedLink() (r string, exists bool) { 373 v := m.feed_link 374 if v == nil { 375 return 376 } 377 return *v, true 378 } 379 380 // OldFeedLink returns the old "feed_link" field's value of the Feed entity. 381 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 382 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 383 func (m *FeedMutation) OldFeedLink(ctx context.Context) (v string, err error) { 384 if !m.op.Is(OpUpdateOne) { 385 return v, errors.New("OldFeedLink is only allowed on UpdateOne operations") 386 } 387 if m.id == nil || m.oldValue == nil { 388 return v, errors.New("OldFeedLink requires an ID field in the mutation") 389 } 390 oldValue, err := m.oldValue(ctx) 391 if err != nil { 392 return v, fmt.Errorf("querying old value for OldFeedLink: %w", err) 393 } 394 return oldValue.FeedLink, nil 395 } 396 397 // ResetFeedLink resets all changes to the "feed_link" field. 398 func (m *FeedMutation) ResetFeedLink() { 399 m.feed_link = nil 400 } 401 402 // SetFeedFeedLink sets the "feed_feed_link" field. 403 func (m *FeedMutation) SetFeedFeedLink(s string) { 404 m.feed_feed_link = &s 405 } 406 407 // FeedFeedLink returns the value of the "feed_feed_link" field in the mutation. 408 func (m *FeedMutation) FeedFeedLink() (r string, exists bool) { 409 v := m.feed_feed_link 410 if v == nil { 411 return 412 } 413 return *v, true 414 } 415 416 // OldFeedFeedLink returns the old "feed_feed_link" field's value of the Feed entity. 417 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 418 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 419 func (m *FeedMutation) OldFeedFeedLink(ctx context.Context) (v string, err error) { 420 if !m.op.Is(OpUpdateOne) { 421 return v, errors.New("OldFeedFeedLink is only allowed on UpdateOne operations") 422 } 423 if m.id == nil || m.oldValue == nil { 424 return v, errors.New("OldFeedFeedLink requires an ID field in the mutation") 425 } 426 oldValue, err := m.oldValue(ctx) 427 if err != nil { 428 return v, fmt.Errorf("querying old value for OldFeedFeedLink: %w", err) 429 } 430 return oldValue.FeedFeedLink, nil 431 } 432 433 // ResetFeedFeedLink resets all changes to the "feed_feed_link" field. 434 func (m *FeedMutation) ResetFeedFeedLink() { 435 m.feed_feed_link = nil 436 } 437 438 // SetFeedUpdated sets the "feed_updated" field. 439 func (m *FeedMutation) SetFeedUpdated(t time.Time) { 440 m.feed_updated = &t 441 } 442 443 // FeedUpdated returns the value of the "feed_updated" field in the mutation. 444 func (m *FeedMutation) FeedUpdated() (r time.Time, exists bool) { 445 v := m.feed_updated 446 if v == nil { 447 return 448 } 449 return *v, true 450 } 451 452 // OldFeedUpdated returns the old "feed_updated" field's value of the Feed entity. 453 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 454 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 455 func (m *FeedMutation) OldFeedUpdated(ctx context.Context) (v time.Time, err error) { 456 if !m.op.Is(OpUpdateOne) { 457 return v, errors.New("OldFeedUpdated is only allowed on UpdateOne operations") 458 } 459 if m.id == nil || m.oldValue == nil { 460 return v, errors.New("OldFeedUpdated requires an ID field in the mutation") 461 } 462 oldValue, err := m.oldValue(ctx) 463 if err != nil { 464 return v, fmt.Errorf("querying old value for OldFeedUpdated: %w", err) 465 } 466 return oldValue.FeedUpdated, nil 467 } 468 469 // ResetFeedUpdated resets all changes to the "feed_updated" field. 470 func (m *FeedMutation) ResetFeedUpdated() { 471 m.feed_updated = nil 472 } 473 474 // SetFeedPublished sets the "feed_published" field. 475 func (m *FeedMutation) SetFeedPublished(t time.Time) { 476 m.feed_published = &t 477 } 478 479 // FeedPublished returns the value of the "feed_published" field in the mutation. 480 func (m *FeedMutation) FeedPublished() (r time.Time, exists bool) { 481 v := m.feed_published 482 if v == nil { 483 return 484 } 485 return *v, true 486 } 487 488 // OldFeedPublished returns the old "feed_published" field's value of the Feed entity. 489 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 490 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 491 func (m *FeedMutation) OldFeedPublished(ctx context.Context) (v time.Time, err error) { 492 if !m.op.Is(OpUpdateOne) { 493 return v, errors.New("OldFeedPublished is only allowed on UpdateOne operations") 494 } 495 if m.id == nil || m.oldValue == nil { 496 return v, errors.New("OldFeedPublished requires an ID field in the mutation") 497 } 498 oldValue, err := m.oldValue(ctx) 499 if err != nil { 500 return v, fmt.Errorf("querying old value for OldFeedPublished: %w", err) 501 } 502 return oldValue.FeedPublished, nil 503 } 504 505 // ResetFeedPublished resets all changes to the "feed_published" field. 506 func (m *FeedMutation) ResetFeedPublished() { 507 m.feed_published = nil 508 } 509 510 // SetFeedAuthorName sets the "feed_author_name" field. 511 func (m *FeedMutation) SetFeedAuthorName(s string) { 512 m.feed_author_name = &s 513 } 514 515 // FeedAuthorName returns the value of the "feed_author_name" field in the mutation. 516 func (m *FeedMutation) FeedAuthorName() (r string, exists bool) { 517 v := m.feed_author_name 518 if v == nil { 519 return 520 } 521 return *v, true 522 } 523 524 // OldFeedAuthorName returns the old "feed_author_name" field's value of the Feed entity. 525 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 526 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 527 func (m *FeedMutation) OldFeedAuthorName(ctx context.Context) (v string, err error) { 528 if !m.op.Is(OpUpdateOne) { 529 return v, errors.New("OldFeedAuthorName is only allowed on UpdateOne operations") 530 } 531 if m.id == nil || m.oldValue == nil { 532 return v, errors.New("OldFeedAuthorName requires an ID field in the mutation") 533 } 534 oldValue, err := m.oldValue(ctx) 535 if err != nil { 536 return v, fmt.Errorf("querying old value for OldFeedAuthorName: %w", err) 537 } 538 return oldValue.FeedAuthorName, nil 539 } 540 541 // ClearFeedAuthorName clears the value of the "feed_author_name" field. 542 func (m *FeedMutation) ClearFeedAuthorName() { 543 m.feed_author_name = nil 544 m.clearedFields[feed.FieldFeedAuthorName] = struct{}{} 545 } 546 547 // FeedAuthorNameCleared returns if the "feed_author_name" field was cleared in this mutation. 548 func (m *FeedMutation) FeedAuthorNameCleared() bool { 549 _, ok := m.clearedFields[feed.FieldFeedAuthorName] 550 return ok 551 } 552 553 // ResetFeedAuthorName resets all changes to the "feed_author_name" field. 554 func (m *FeedMutation) ResetFeedAuthorName() { 555 m.feed_author_name = nil 556 delete(m.clearedFields, feed.FieldFeedAuthorName) 557 } 558 559 // SetFeedAuthorEmail sets the "feed_author_email" field. 560 func (m *FeedMutation) SetFeedAuthorEmail(s string) { 561 m.feed_author_email = &s 562 } 563 564 // FeedAuthorEmail returns the value of the "feed_author_email" field in the mutation. 565 func (m *FeedMutation) FeedAuthorEmail() (r string, exists bool) { 566 v := m.feed_author_email 567 if v == nil { 568 return 569 } 570 return *v, true 571 } 572 573 // OldFeedAuthorEmail returns the old "feed_author_email" field's value of the Feed entity. 574 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 575 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 576 func (m *FeedMutation) OldFeedAuthorEmail(ctx context.Context) (v string, err error) { 577 if !m.op.Is(OpUpdateOne) { 578 return v, errors.New("OldFeedAuthorEmail is only allowed on UpdateOne operations") 579 } 580 if m.id == nil || m.oldValue == nil { 581 return v, errors.New("OldFeedAuthorEmail requires an ID field in the mutation") 582 } 583 oldValue, err := m.oldValue(ctx) 584 if err != nil { 585 return v, fmt.Errorf("querying old value for OldFeedAuthorEmail: %w", err) 586 } 587 return oldValue.FeedAuthorEmail, nil 588 } 589 590 // ClearFeedAuthorEmail clears the value of the "feed_author_email" field. 591 func (m *FeedMutation) ClearFeedAuthorEmail() { 592 m.feed_author_email = nil 593 m.clearedFields[feed.FieldFeedAuthorEmail] = struct{}{} 594 } 595 596 // FeedAuthorEmailCleared returns if the "feed_author_email" field was cleared in this mutation. 597 func (m *FeedMutation) FeedAuthorEmailCleared() bool { 598 _, ok := m.clearedFields[feed.FieldFeedAuthorEmail] 599 return ok 600 } 601 602 // ResetFeedAuthorEmail resets all changes to the "feed_author_email" field. 603 func (m *FeedMutation) ResetFeedAuthorEmail() { 604 m.feed_author_email = nil 605 delete(m.clearedFields, feed.FieldFeedAuthorEmail) 606 } 607 608 // SetFeedLanguage sets the "feed_language" field. 609 func (m *FeedMutation) SetFeedLanguage(s string) { 610 m.feed_language = &s 611 } 612 613 // FeedLanguage returns the value of the "feed_language" field in the mutation. 614 func (m *FeedMutation) FeedLanguage() (r string, exists bool) { 615 v := m.feed_language 616 if v == nil { 617 return 618 } 619 return *v, true 620 } 621 622 // OldFeedLanguage returns the old "feed_language" field's value of the Feed entity. 623 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 624 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 625 func (m *FeedMutation) OldFeedLanguage(ctx context.Context) (v string, err error) { 626 if !m.op.Is(OpUpdateOne) { 627 return v, errors.New("OldFeedLanguage is only allowed on UpdateOne operations") 628 } 629 if m.id == nil || m.oldValue == nil { 630 return v, errors.New("OldFeedLanguage requires an ID field in the mutation") 631 } 632 oldValue, err := m.oldValue(ctx) 633 if err != nil { 634 return v, fmt.Errorf("querying old value for OldFeedLanguage: %w", err) 635 } 636 return oldValue.FeedLanguage, nil 637 } 638 639 // ResetFeedLanguage resets all changes to the "feed_language" field. 640 func (m *FeedMutation) ResetFeedLanguage() { 641 m.feed_language = nil 642 } 643 644 // SetFeedImageTitle sets the "feed_image_title" field. 645 func (m *FeedMutation) SetFeedImageTitle(s string) { 646 m.feed_image_title = &s 647 } 648 649 // FeedImageTitle returns the value of the "feed_image_title" field in the mutation. 650 func (m *FeedMutation) FeedImageTitle() (r string, exists bool) { 651 v := m.feed_image_title 652 if v == nil { 653 return 654 } 655 return *v, true 656 } 657 658 // OldFeedImageTitle returns the old "feed_image_title" field's value of the Feed entity. 659 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 660 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 661 func (m *FeedMutation) OldFeedImageTitle(ctx context.Context) (v string, err error) { 662 if !m.op.Is(OpUpdateOne) { 663 return v, errors.New("OldFeedImageTitle is only allowed on UpdateOne operations") 664 } 665 if m.id == nil || m.oldValue == nil { 666 return v, errors.New("OldFeedImageTitle requires an ID field in the mutation") 667 } 668 oldValue, err := m.oldValue(ctx) 669 if err != nil { 670 return v, fmt.Errorf("querying old value for OldFeedImageTitle: %w", err) 671 } 672 return oldValue.FeedImageTitle, nil 673 } 674 675 // ClearFeedImageTitle clears the value of the "feed_image_title" field. 676 func (m *FeedMutation) ClearFeedImageTitle() { 677 m.feed_image_title = nil 678 m.clearedFields[feed.FieldFeedImageTitle] = struct{}{} 679 } 680 681 // FeedImageTitleCleared returns if the "feed_image_title" field was cleared in this mutation. 682 func (m *FeedMutation) FeedImageTitleCleared() bool { 683 _, ok := m.clearedFields[feed.FieldFeedImageTitle] 684 return ok 685 } 686 687 // ResetFeedImageTitle resets all changes to the "feed_image_title" field. 688 func (m *FeedMutation) ResetFeedImageTitle() { 689 m.feed_image_title = nil 690 delete(m.clearedFields, feed.FieldFeedImageTitle) 691 } 692 693 // SetFeedImageURL sets the "feed_image_url" field. 694 func (m *FeedMutation) SetFeedImageURL(s string) { 695 m.feed_image_url = &s 696 } 697 698 // FeedImageURL returns the value of the "feed_image_url" field in the mutation. 699 func (m *FeedMutation) FeedImageURL() (r string, exists bool) { 700 v := m.feed_image_url 701 if v == nil { 702 return 703 } 704 return *v, true 705 } 706 707 // OldFeedImageURL returns the old "feed_image_url" field's value of the Feed entity. 708 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 709 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 710 func (m *FeedMutation) OldFeedImageURL(ctx context.Context) (v string, err error) { 711 if !m.op.Is(OpUpdateOne) { 712 return v, errors.New("OldFeedImageURL is only allowed on UpdateOne operations") 713 } 714 if m.id == nil || m.oldValue == nil { 715 return v, errors.New("OldFeedImageURL requires an ID field in the mutation") 716 } 717 oldValue, err := m.oldValue(ctx) 718 if err != nil { 719 return v, fmt.Errorf("querying old value for OldFeedImageURL: %w", err) 720 } 721 return oldValue.FeedImageURL, nil 722 } 723 724 // ClearFeedImageURL clears the value of the "feed_image_url" field. 725 func (m *FeedMutation) ClearFeedImageURL() { 726 m.feed_image_url = nil 727 m.clearedFields[feed.FieldFeedImageURL] = struct{}{} 728 } 729 730 // FeedImageURLCleared returns if the "feed_image_url" field was cleared in this mutation. 731 func (m *FeedMutation) FeedImageURLCleared() bool { 732 _, ok := m.clearedFields[feed.FieldFeedImageURL] 733 return ok 734 } 735 736 // ResetFeedImageURL resets all changes to the "feed_image_url" field. 737 func (m *FeedMutation) ResetFeedImageURL() { 738 m.feed_image_url = nil 739 delete(m.clearedFields, feed.FieldFeedImageURL) 740 } 741 742 // SetFeedCopyright sets the "feed_copyright" field. 743 func (m *FeedMutation) SetFeedCopyright(s string) { 744 m.feed_copyright = &s 745 } 746 747 // FeedCopyright returns the value of the "feed_copyright" field in the mutation. 748 func (m *FeedMutation) FeedCopyright() (r string, exists bool) { 749 v := m.feed_copyright 750 if v == nil { 751 return 752 } 753 return *v, true 754 } 755 756 // OldFeedCopyright returns the old "feed_copyright" field's value of the Feed entity. 757 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 758 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 759 func (m *FeedMutation) OldFeedCopyright(ctx context.Context) (v string, err error) { 760 if !m.op.Is(OpUpdateOne) { 761 return v, errors.New("OldFeedCopyright is only allowed on UpdateOne operations") 762 } 763 if m.id == nil || m.oldValue == nil { 764 return v, errors.New("OldFeedCopyright requires an ID field in the mutation") 765 } 766 oldValue, err := m.oldValue(ctx) 767 if err != nil { 768 return v, fmt.Errorf("querying old value for OldFeedCopyright: %w", err) 769 } 770 return oldValue.FeedCopyright, nil 771 } 772 773 // ResetFeedCopyright resets all changes to the "feed_copyright" field. 774 func (m *FeedMutation) ResetFeedCopyright() { 775 m.feed_copyright = nil 776 } 777 778 // SetFeedGenerator sets the "feed_generator" field. 779 func (m *FeedMutation) SetFeedGenerator(s string) { 780 m.feed_generator = &s 781 } 782 783 // FeedGenerator returns the value of the "feed_generator" field in the mutation. 784 func (m *FeedMutation) FeedGenerator() (r string, exists bool) { 785 v := m.feed_generator 786 if v == nil { 787 return 788 } 789 return *v, true 790 } 791 792 // OldFeedGenerator returns the old "feed_generator" field's value of the Feed entity. 793 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 794 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 795 func (m *FeedMutation) OldFeedGenerator(ctx context.Context) (v string, err error) { 796 if !m.op.Is(OpUpdateOne) { 797 return v, errors.New("OldFeedGenerator is only allowed on UpdateOne operations") 798 } 799 if m.id == nil || m.oldValue == nil { 800 return v, errors.New("OldFeedGenerator requires an ID field in the mutation") 801 } 802 oldValue, err := m.oldValue(ctx) 803 if err != nil { 804 return v, fmt.Errorf("querying old value for OldFeedGenerator: %w", err) 805 } 806 return oldValue.FeedGenerator, nil 807 } 808 809 // ResetFeedGenerator resets all changes to the "feed_generator" field. 810 func (m *FeedMutation) ResetFeedGenerator() { 811 m.feed_generator = nil 812 } 813 814 // SetFeedCategories sets the "feed_categories" field. 815 func (m *FeedMutation) SetFeedCategories(s string) { 816 m.feed_categories = &s 817 } 818 819 // FeedCategories returns the value of the "feed_categories" field in the mutation. 820 func (m *FeedMutation) FeedCategories() (r string, exists bool) { 821 v := m.feed_categories 822 if v == nil { 823 return 824 } 825 return *v, true 826 } 827 828 // OldFeedCategories returns the old "feed_categories" field's value of the Feed entity. 829 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 830 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 831 func (m *FeedMutation) OldFeedCategories(ctx context.Context) (v string, err error) { 832 if !m.op.Is(OpUpdateOne) { 833 return v, errors.New("OldFeedCategories is only allowed on UpdateOne operations") 834 } 835 if m.id == nil || m.oldValue == nil { 836 return v, errors.New("OldFeedCategories requires an ID field in the mutation") 837 } 838 oldValue, err := m.oldValue(ctx) 839 if err != nil { 840 return v, fmt.Errorf("querying old value for OldFeedCategories: %w", err) 841 } 842 return oldValue.FeedCategories, nil 843 } 844 845 // ResetFeedCategories resets all changes to the "feed_categories" field. 846 func (m *FeedMutation) ResetFeedCategories() { 847 m.feed_categories = nil 848 } 849 850 // SetCreatedAt sets the "created_at" field. 851 func (m *FeedMutation) SetCreatedAt(t time.Time) { 852 m.created_at = &t 853 } 854 855 // CreatedAt returns the value of the "created_at" field in the mutation. 856 func (m *FeedMutation) CreatedAt() (r time.Time, exists bool) { 857 v := m.created_at 858 if v == nil { 859 return 860 } 861 return *v, true 862 } 863 864 // OldCreatedAt returns the old "created_at" field's value of the Feed entity. 865 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 866 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 867 func (m *FeedMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { 868 if !m.op.Is(OpUpdateOne) { 869 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 870 } 871 if m.id == nil || m.oldValue == nil { 872 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 873 } 874 oldValue, err := m.oldValue(ctx) 875 if err != nil { 876 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 877 } 878 return oldValue.CreatedAt, nil 879 } 880 881 // ResetCreatedAt resets all changes to the "created_at" field. 882 func (m *FeedMutation) ResetCreatedAt() { 883 m.created_at = nil 884 } 885 886 // SetUpdatedAt sets the "updated_at" field. 887 func (m *FeedMutation) SetUpdatedAt(t time.Time) { 888 m.updated_at = &t 889 } 890 891 // UpdatedAt returns the value of the "updated_at" field in the mutation. 892 func (m *FeedMutation) UpdatedAt() (r time.Time, exists bool) { 893 v := m.updated_at 894 if v == nil { 895 return 896 } 897 return *v, true 898 } 899 900 // OldUpdatedAt returns the old "updated_at" field's value of the Feed entity. 901 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 902 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 903 func (m *FeedMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { 904 if !m.op.Is(OpUpdateOne) { 905 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 906 } 907 if m.id == nil || m.oldValue == nil { 908 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 909 } 910 oldValue, err := m.oldValue(ctx) 911 if err != nil { 912 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 913 } 914 return oldValue.UpdatedAt, nil 915 } 916 917 // ResetUpdatedAt resets all changes to the "updated_at" field. 918 func (m *FeedMutation) ResetUpdatedAt() { 919 m.updated_at = nil 920 } 921 922 // SetDeletedAt sets the "deleted_at" field. 923 func (m *FeedMutation) SetDeletedAt(t time.Time) { 924 m.deleted_at = &t 925 } 926 927 // DeletedAt returns the value of the "deleted_at" field in the mutation. 928 func (m *FeedMutation) DeletedAt() (r time.Time, exists bool) { 929 v := m.deleted_at 930 if v == nil { 931 return 932 } 933 return *v, true 934 } 935 936 // OldDeletedAt returns the old "deleted_at" field's value of the Feed entity. 937 // If the Feed object wasn't provided to the builder, the object is fetched from the database. 938 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 939 func (m *FeedMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) { 940 if !m.op.Is(OpUpdateOne) { 941 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 942 } 943 if m.id == nil || m.oldValue == nil { 944 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 945 } 946 oldValue, err := m.oldValue(ctx) 947 if err != nil { 948 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 949 } 950 return oldValue.DeletedAt, nil 951 } 952 953 // ClearDeletedAt clears the value of the "deleted_at" field. 954 func (m *FeedMutation) ClearDeletedAt() { 955 m.deleted_at = nil 956 m.clearedFields[feed.FieldDeletedAt] = struct{}{} 957 } 958 959 // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. 960 func (m *FeedMutation) DeletedAtCleared() bool { 961 _, ok := m.clearedFields[feed.FieldDeletedAt] 962 return ok 963 } 964 965 // ResetDeletedAt resets all changes to the "deleted_at" field. 966 func (m *FeedMutation) ResetDeletedAt() { 967 m.deleted_at = nil 968 delete(m.clearedFields, feed.FieldDeletedAt) 969 } 970 971 // AddItemIDs adds the "items" edge to the Item entity by ids. 972 func (m *FeedMutation) AddItemIDs(ids ...uuid.UUID) { 973 if m.items == nil { 974 m.items = make(map[uuid.UUID]struct{}) 975 } 976 for i := range ids { 977 m.items[ids[i]] = struct{}{} 978 } 979 } 980 981 // ClearItems clears the "items" edge to the Item entity. 982 func (m *FeedMutation) ClearItems() { 983 m.cleareditems = true 984 } 985 986 // ItemsCleared reports if the "items" edge to the Item entity was cleared. 987 func (m *FeedMutation) ItemsCleared() bool { 988 return m.cleareditems 989 } 990 991 // RemoveItemIDs removes the "items" edge to the Item entity by IDs. 992 func (m *FeedMutation) RemoveItemIDs(ids ...uuid.UUID) { 993 if m.removeditems == nil { 994 m.removeditems = make(map[uuid.UUID]struct{}) 995 } 996 for i := range ids { 997 delete(m.items, ids[i]) 998 m.removeditems[ids[i]] = struct{}{} 999 } 1000 } 1001 1002 // RemovedItems returns the removed IDs of the "items" edge to the Item entity. 1003 func (m *FeedMutation) RemovedItemsIDs() (ids []uuid.UUID) { 1004 for id := range m.removeditems { 1005 ids = append(ids, id) 1006 } 1007 return 1008 } 1009 1010 // ItemsIDs returns the "items" edge IDs in the mutation. 1011 func (m *FeedMutation) ItemsIDs() (ids []uuid.UUID) { 1012 for id := range m.items { 1013 ids = append(ids, id) 1014 } 1015 return 1016 } 1017 1018 // ResetItems resets all changes to the "items" edge. 1019 func (m *FeedMutation) ResetItems() { 1020 m.items = nil 1021 m.cleareditems = false 1022 m.removeditems = nil 1023 } 1024 1025 // AddSubscribedUserIDs adds the "subscribed_users" edge to the User entity by ids. 1026 func (m *FeedMutation) AddSubscribedUserIDs(ids ...uuid.UUID) { 1027 if m.subscribed_users == nil { 1028 m.subscribed_users = make(map[uuid.UUID]struct{}) 1029 } 1030 for i := range ids { 1031 m.subscribed_users[ids[i]] = struct{}{} 1032 } 1033 } 1034 1035 // ClearSubscribedUsers clears the "subscribed_users" edge to the User entity. 1036 func (m *FeedMutation) ClearSubscribedUsers() { 1037 m.clearedsubscribed_users = true 1038 } 1039 1040 // SubscribedUsersCleared reports if the "subscribed_users" edge to the User entity was cleared. 1041 func (m *FeedMutation) SubscribedUsersCleared() bool { 1042 return m.clearedsubscribed_users 1043 } 1044 1045 // RemoveSubscribedUserIDs removes the "subscribed_users" edge to the User entity by IDs. 1046 func (m *FeedMutation) RemoveSubscribedUserIDs(ids ...uuid.UUID) { 1047 if m.removedsubscribed_users == nil { 1048 m.removedsubscribed_users = make(map[uuid.UUID]struct{}) 1049 } 1050 for i := range ids { 1051 delete(m.subscribed_users, ids[i]) 1052 m.removedsubscribed_users[ids[i]] = struct{}{} 1053 } 1054 } 1055 1056 // RemovedSubscribedUsers returns the removed IDs of the "subscribed_users" edge to the User entity. 1057 func (m *FeedMutation) RemovedSubscribedUsersIDs() (ids []uuid.UUID) { 1058 for id := range m.removedsubscribed_users { 1059 ids = append(ids, id) 1060 } 1061 return 1062 } 1063 1064 // SubscribedUsersIDs returns the "subscribed_users" edge IDs in the mutation. 1065 func (m *FeedMutation) SubscribedUsersIDs() (ids []uuid.UUID) { 1066 for id := range m.subscribed_users { 1067 ids = append(ids, id) 1068 } 1069 return 1070 } 1071 1072 // ResetSubscribedUsers resets all changes to the "subscribed_users" edge. 1073 func (m *FeedMutation) ResetSubscribedUsers() { 1074 m.subscribed_users = nil 1075 m.clearedsubscribed_users = false 1076 m.removedsubscribed_users = nil 1077 } 1078 1079 // AddSubscriptionIDs adds the "subscriptions" edge to the Subscription entity by ids. 1080 func (m *FeedMutation) AddSubscriptionIDs(ids ...uuid.UUID) { 1081 if m.subscriptions == nil { 1082 m.subscriptions = make(map[uuid.UUID]struct{}) 1083 } 1084 for i := range ids { 1085 m.subscriptions[ids[i]] = struct{}{} 1086 } 1087 } 1088 1089 // ClearSubscriptions clears the "subscriptions" edge to the Subscription entity. 1090 func (m *FeedMutation) ClearSubscriptions() { 1091 m.clearedsubscriptions = true 1092 } 1093 1094 // SubscriptionsCleared reports if the "subscriptions" edge to the Subscription entity was cleared. 1095 func (m *FeedMutation) SubscriptionsCleared() bool { 1096 return m.clearedsubscriptions 1097 } 1098 1099 // RemoveSubscriptionIDs removes the "subscriptions" edge to the Subscription entity by IDs. 1100 func (m *FeedMutation) RemoveSubscriptionIDs(ids ...uuid.UUID) { 1101 if m.removedsubscriptions == nil { 1102 m.removedsubscriptions = make(map[uuid.UUID]struct{}) 1103 } 1104 for i := range ids { 1105 delete(m.subscriptions, ids[i]) 1106 m.removedsubscriptions[ids[i]] = struct{}{} 1107 } 1108 } 1109 1110 // RemovedSubscriptions returns the removed IDs of the "subscriptions" edge to the Subscription entity. 1111 func (m *FeedMutation) RemovedSubscriptionsIDs() (ids []uuid.UUID) { 1112 for id := range m.removedsubscriptions { 1113 ids = append(ids, id) 1114 } 1115 return 1116 } 1117 1118 // SubscriptionsIDs returns the "subscriptions" edge IDs in the mutation. 1119 func (m *FeedMutation) SubscriptionsIDs() (ids []uuid.UUID) { 1120 for id := range m.subscriptions { 1121 ids = append(ids, id) 1122 } 1123 return 1124 } 1125 1126 // ResetSubscriptions resets all changes to the "subscriptions" edge. 1127 func (m *FeedMutation) ResetSubscriptions() { 1128 m.subscriptions = nil 1129 m.clearedsubscriptions = false 1130 m.removedsubscriptions = nil 1131 } 1132 1133 // Where appends a list predicates to the FeedMutation builder. 1134 func (m *FeedMutation) Where(ps ...predicate.Feed) { 1135 m.predicates = append(m.predicates, ps...) 1136 } 1137 1138 // WhereP appends storage-level predicates to the FeedMutation builder. Using this method, 1139 // users can use type-assertion to append predicates that do not depend on any generated package. 1140 func (m *FeedMutation) WhereP(ps ...func(*sql.Selector)) { 1141 p := make([]predicate.Feed, len(ps)) 1142 for i := range ps { 1143 p[i] = ps[i] 1144 } 1145 m.Where(p...) 1146 } 1147 1148 // Op returns the operation name. 1149 func (m *FeedMutation) Op() Op { 1150 return m.op 1151 } 1152 1153 // SetOp allows setting the mutation operation. 1154 func (m *FeedMutation) SetOp(op Op) { 1155 m.op = op 1156 } 1157 1158 // Type returns the node type of this mutation (Feed). 1159 func (m *FeedMutation) Type() string { 1160 return m.typ 1161 } 1162 1163 // Fields returns all fields that were changed during this mutation. Note that in 1164 // order to get all numeric fields that were incremented/decremented, call 1165 // AddedFields(). 1166 func (m *FeedMutation) Fields() []string { 1167 fields := make([]string, 0, 20) 1168 if m.url != nil { 1169 fields = append(fields, feed.FieldURL) 1170 } 1171 if m.username != nil { 1172 fields = append(fields, feed.FieldUsername) 1173 } 1174 if m.password != nil { 1175 fields = append(fields, feed.FieldPassword) 1176 } 1177 if m.feed_title != nil { 1178 fields = append(fields, feed.FieldFeedTitle) 1179 } 1180 if m.feed_description != nil { 1181 fields = append(fields, feed.FieldFeedDescription) 1182 } 1183 if m.feed_link != nil { 1184 fields = append(fields, feed.FieldFeedLink) 1185 } 1186 if m.feed_feed_link != nil { 1187 fields = append(fields, feed.FieldFeedFeedLink) 1188 } 1189 if m.feed_updated != nil { 1190 fields = append(fields, feed.FieldFeedUpdated) 1191 } 1192 if m.feed_published != nil { 1193 fields = append(fields, feed.FieldFeedPublished) 1194 } 1195 if m.feed_author_name != nil { 1196 fields = append(fields, feed.FieldFeedAuthorName) 1197 } 1198 if m.feed_author_email != nil { 1199 fields = append(fields, feed.FieldFeedAuthorEmail) 1200 } 1201 if m.feed_language != nil { 1202 fields = append(fields, feed.FieldFeedLanguage) 1203 } 1204 if m.feed_image_title != nil { 1205 fields = append(fields, feed.FieldFeedImageTitle) 1206 } 1207 if m.feed_image_url != nil { 1208 fields = append(fields, feed.FieldFeedImageURL) 1209 } 1210 if m.feed_copyright != nil { 1211 fields = append(fields, feed.FieldFeedCopyright) 1212 } 1213 if m.feed_generator != nil { 1214 fields = append(fields, feed.FieldFeedGenerator) 1215 } 1216 if m.feed_categories != nil { 1217 fields = append(fields, feed.FieldFeedCategories) 1218 } 1219 if m.created_at != nil { 1220 fields = append(fields, feed.FieldCreatedAt) 1221 } 1222 if m.updated_at != nil { 1223 fields = append(fields, feed.FieldUpdatedAt) 1224 } 1225 if m.deleted_at != nil { 1226 fields = append(fields, feed.FieldDeletedAt) 1227 } 1228 return fields 1229 } 1230 1231 // Field returns the value of a field with the given name. The second boolean 1232 // return value indicates that this field was not set, or was not defined in the 1233 // schema. 1234 func (m *FeedMutation) Field(name string) (ent.Value, bool) { 1235 switch name { 1236 case feed.FieldURL: 1237 return m.URL() 1238 case feed.FieldUsername: 1239 return m.Username() 1240 case feed.FieldPassword: 1241 return m.Password() 1242 case feed.FieldFeedTitle: 1243 return m.FeedTitle() 1244 case feed.FieldFeedDescription: 1245 return m.FeedDescription() 1246 case feed.FieldFeedLink: 1247 return m.FeedLink() 1248 case feed.FieldFeedFeedLink: 1249 return m.FeedFeedLink() 1250 case feed.FieldFeedUpdated: 1251 return m.FeedUpdated() 1252 case feed.FieldFeedPublished: 1253 return m.FeedPublished() 1254 case feed.FieldFeedAuthorName: 1255 return m.FeedAuthorName() 1256 case feed.FieldFeedAuthorEmail: 1257 return m.FeedAuthorEmail() 1258 case feed.FieldFeedLanguage: 1259 return m.FeedLanguage() 1260 case feed.FieldFeedImageTitle: 1261 return m.FeedImageTitle() 1262 case feed.FieldFeedImageURL: 1263 return m.FeedImageURL() 1264 case feed.FieldFeedCopyright: 1265 return m.FeedCopyright() 1266 case feed.FieldFeedGenerator: 1267 return m.FeedGenerator() 1268 case feed.FieldFeedCategories: 1269 return m.FeedCategories() 1270 case feed.FieldCreatedAt: 1271 return m.CreatedAt() 1272 case feed.FieldUpdatedAt: 1273 return m.UpdatedAt() 1274 case feed.FieldDeletedAt: 1275 return m.DeletedAt() 1276 } 1277 return nil, false 1278 } 1279 1280 // OldField returns the old value of the field from the database. An error is 1281 // returned if the mutation operation is not UpdateOne, or the query to the 1282 // database failed. 1283 func (m *FeedMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 1284 switch name { 1285 case feed.FieldURL: 1286 return m.OldURL(ctx) 1287 case feed.FieldUsername: 1288 return m.OldUsername(ctx) 1289 case feed.FieldPassword: 1290 return m.OldPassword(ctx) 1291 case feed.FieldFeedTitle: 1292 return m.OldFeedTitle(ctx) 1293 case feed.FieldFeedDescription: 1294 return m.OldFeedDescription(ctx) 1295 case feed.FieldFeedLink: 1296 return m.OldFeedLink(ctx) 1297 case feed.FieldFeedFeedLink: 1298 return m.OldFeedFeedLink(ctx) 1299 case feed.FieldFeedUpdated: 1300 return m.OldFeedUpdated(ctx) 1301 case feed.FieldFeedPublished: 1302 return m.OldFeedPublished(ctx) 1303 case feed.FieldFeedAuthorName: 1304 return m.OldFeedAuthorName(ctx) 1305 case feed.FieldFeedAuthorEmail: 1306 return m.OldFeedAuthorEmail(ctx) 1307 case feed.FieldFeedLanguage: 1308 return m.OldFeedLanguage(ctx) 1309 case feed.FieldFeedImageTitle: 1310 return m.OldFeedImageTitle(ctx) 1311 case feed.FieldFeedImageURL: 1312 return m.OldFeedImageURL(ctx) 1313 case feed.FieldFeedCopyright: 1314 return m.OldFeedCopyright(ctx) 1315 case feed.FieldFeedGenerator: 1316 return m.OldFeedGenerator(ctx) 1317 case feed.FieldFeedCategories: 1318 return m.OldFeedCategories(ctx) 1319 case feed.FieldCreatedAt: 1320 return m.OldCreatedAt(ctx) 1321 case feed.FieldUpdatedAt: 1322 return m.OldUpdatedAt(ctx) 1323 case feed.FieldDeletedAt: 1324 return m.OldDeletedAt(ctx) 1325 } 1326 return nil, fmt.Errorf("unknown Feed field %s", name) 1327 } 1328 1329 // SetField sets the value of a field with the given name. It returns an error if 1330 // the field is not defined in the schema, or if the type mismatched the field 1331 // type. 1332 func (m *FeedMutation) SetField(name string, value ent.Value) error { 1333 switch name { 1334 case feed.FieldURL: 1335 v, ok := value.(string) 1336 if !ok { 1337 return fmt.Errorf("unexpected type %T for field %s", value, name) 1338 } 1339 m.SetURL(v) 1340 return nil 1341 case feed.FieldUsername: 1342 v, ok := value.(string) 1343 if !ok { 1344 return fmt.Errorf("unexpected type %T for field %s", value, name) 1345 } 1346 m.SetUsername(v) 1347 return nil 1348 case feed.FieldPassword: 1349 v, ok := value.(string) 1350 if !ok { 1351 return fmt.Errorf("unexpected type %T for field %s", value, name) 1352 } 1353 m.SetPassword(v) 1354 return nil 1355 case feed.FieldFeedTitle: 1356 v, ok := value.(string) 1357 if !ok { 1358 return fmt.Errorf("unexpected type %T for field %s", value, name) 1359 } 1360 m.SetFeedTitle(v) 1361 return nil 1362 case feed.FieldFeedDescription: 1363 v, ok := value.(string) 1364 if !ok { 1365 return fmt.Errorf("unexpected type %T for field %s", value, name) 1366 } 1367 m.SetFeedDescription(v) 1368 return nil 1369 case feed.FieldFeedLink: 1370 v, ok := value.(string) 1371 if !ok { 1372 return fmt.Errorf("unexpected type %T for field %s", value, name) 1373 } 1374 m.SetFeedLink(v) 1375 return nil 1376 case feed.FieldFeedFeedLink: 1377 v, ok := value.(string) 1378 if !ok { 1379 return fmt.Errorf("unexpected type %T for field %s", value, name) 1380 } 1381 m.SetFeedFeedLink(v) 1382 return nil 1383 case feed.FieldFeedUpdated: 1384 v, ok := value.(time.Time) 1385 if !ok { 1386 return fmt.Errorf("unexpected type %T for field %s", value, name) 1387 } 1388 m.SetFeedUpdated(v) 1389 return nil 1390 case feed.FieldFeedPublished: 1391 v, ok := value.(time.Time) 1392 if !ok { 1393 return fmt.Errorf("unexpected type %T for field %s", value, name) 1394 } 1395 m.SetFeedPublished(v) 1396 return nil 1397 case feed.FieldFeedAuthorName: 1398 v, ok := value.(string) 1399 if !ok { 1400 return fmt.Errorf("unexpected type %T for field %s", value, name) 1401 } 1402 m.SetFeedAuthorName(v) 1403 return nil 1404 case feed.FieldFeedAuthorEmail: 1405 v, ok := value.(string) 1406 if !ok { 1407 return fmt.Errorf("unexpected type %T for field %s", value, name) 1408 } 1409 m.SetFeedAuthorEmail(v) 1410 return nil 1411 case feed.FieldFeedLanguage: 1412 v, ok := value.(string) 1413 if !ok { 1414 return fmt.Errorf("unexpected type %T for field %s", value, name) 1415 } 1416 m.SetFeedLanguage(v) 1417 return nil 1418 case feed.FieldFeedImageTitle: 1419 v, ok := value.(string) 1420 if !ok { 1421 return fmt.Errorf("unexpected type %T for field %s", value, name) 1422 } 1423 m.SetFeedImageTitle(v) 1424 return nil 1425 case feed.FieldFeedImageURL: 1426 v, ok := value.(string) 1427 if !ok { 1428 return fmt.Errorf("unexpected type %T for field %s", value, name) 1429 } 1430 m.SetFeedImageURL(v) 1431 return nil 1432 case feed.FieldFeedCopyright: 1433 v, ok := value.(string) 1434 if !ok { 1435 return fmt.Errorf("unexpected type %T for field %s", value, name) 1436 } 1437 m.SetFeedCopyright(v) 1438 return nil 1439 case feed.FieldFeedGenerator: 1440 v, ok := value.(string) 1441 if !ok { 1442 return fmt.Errorf("unexpected type %T for field %s", value, name) 1443 } 1444 m.SetFeedGenerator(v) 1445 return nil 1446 case feed.FieldFeedCategories: 1447 v, ok := value.(string) 1448 if !ok { 1449 return fmt.Errorf("unexpected type %T for field %s", value, name) 1450 } 1451 m.SetFeedCategories(v) 1452 return nil 1453 case feed.FieldCreatedAt: 1454 v, ok := value.(time.Time) 1455 if !ok { 1456 return fmt.Errorf("unexpected type %T for field %s", value, name) 1457 } 1458 m.SetCreatedAt(v) 1459 return nil 1460 case feed.FieldUpdatedAt: 1461 v, ok := value.(time.Time) 1462 if !ok { 1463 return fmt.Errorf("unexpected type %T for field %s", value, name) 1464 } 1465 m.SetUpdatedAt(v) 1466 return nil 1467 case feed.FieldDeletedAt: 1468 v, ok := value.(time.Time) 1469 if !ok { 1470 return fmt.Errorf("unexpected type %T for field %s", value, name) 1471 } 1472 m.SetDeletedAt(v) 1473 return nil 1474 } 1475 return fmt.Errorf("unknown Feed field %s", name) 1476 } 1477 1478 // AddedFields returns all numeric fields that were incremented/decremented during 1479 // this mutation. 1480 func (m *FeedMutation) AddedFields() []string { 1481 return nil 1482 } 1483 1484 // AddedField returns the numeric value that was incremented/decremented on a field 1485 // with the given name. The second boolean return value indicates that this field 1486 // was not set, or was not defined in the schema. 1487 func (m *FeedMutation) AddedField(name string) (ent.Value, bool) { 1488 return nil, false 1489 } 1490 1491 // AddField adds the value to the field with the given name. It returns an error if 1492 // the field is not defined in the schema, or if the type mismatched the field 1493 // type. 1494 func (m *FeedMutation) AddField(name string, value ent.Value) error { 1495 switch name { 1496 } 1497 return fmt.Errorf("unknown Feed numeric field %s", name) 1498 } 1499 1500 // ClearedFields returns all nullable fields that were cleared during this 1501 // mutation. 1502 func (m *FeedMutation) ClearedFields() []string { 1503 var fields []string 1504 if m.FieldCleared(feed.FieldFeedAuthorName) { 1505 fields = append(fields, feed.FieldFeedAuthorName) 1506 } 1507 if m.FieldCleared(feed.FieldFeedAuthorEmail) { 1508 fields = append(fields, feed.FieldFeedAuthorEmail) 1509 } 1510 if m.FieldCleared(feed.FieldFeedImageTitle) { 1511 fields = append(fields, feed.FieldFeedImageTitle) 1512 } 1513 if m.FieldCleared(feed.FieldFeedImageURL) { 1514 fields = append(fields, feed.FieldFeedImageURL) 1515 } 1516 if m.FieldCleared(feed.FieldDeletedAt) { 1517 fields = append(fields, feed.FieldDeletedAt) 1518 } 1519 return fields 1520 } 1521 1522 // FieldCleared returns a boolean indicating if a field with the given name was 1523 // cleared in this mutation. 1524 func (m *FeedMutation) FieldCleared(name string) bool { 1525 _, ok := m.clearedFields[name] 1526 return ok 1527 } 1528 1529 // ClearField clears the value of the field with the given name. It returns an 1530 // error if the field is not defined in the schema. 1531 func (m *FeedMutation) ClearField(name string) error { 1532 switch name { 1533 case feed.FieldFeedAuthorName: 1534 m.ClearFeedAuthorName() 1535 return nil 1536 case feed.FieldFeedAuthorEmail: 1537 m.ClearFeedAuthorEmail() 1538 return nil 1539 case feed.FieldFeedImageTitle: 1540 m.ClearFeedImageTitle() 1541 return nil 1542 case feed.FieldFeedImageURL: 1543 m.ClearFeedImageURL() 1544 return nil 1545 case feed.FieldDeletedAt: 1546 m.ClearDeletedAt() 1547 return nil 1548 } 1549 return fmt.Errorf("unknown Feed nullable field %s", name) 1550 } 1551 1552 // ResetField resets all changes in the mutation for the field with the given name. 1553 // It returns an error if the field is not defined in the schema. 1554 func (m *FeedMutation) ResetField(name string) error { 1555 switch name { 1556 case feed.FieldURL: 1557 m.ResetURL() 1558 return nil 1559 case feed.FieldUsername: 1560 m.ResetUsername() 1561 return nil 1562 case feed.FieldPassword: 1563 m.ResetPassword() 1564 return nil 1565 case feed.FieldFeedTitle: 1566 m.ResetFeedTitle() 1567 return nil 1568 case feed.FieldFeedDescription: 1569 m.ResetFeedDescription() 1570 return nil 1571 case feed.FieldFeedLink: 1572 m.ResetFeedLink() 1573 return nil 1574 case feed.FieldFeedFeedLink: 1575 m.ResetFeedFeedLink() 1576 return nil 1577 case feed.FieldFeedUpdated: 1578 m.ResetFeedUpdated() 1579 return nil 1580 case feed.FieldFeedPublished: 1581 m.ResetFeedPublished() 1582 return nil 1583 case feed.FieldFeedAuthorName: 1584 m.ResetFeedAuthorName() 1585 return nil 1586 case feed.FieldFeedAuthorEmail: 1587 m.ResetFeedAuthorEmail() 1588 return nil 1589 case feed.FieldFeedLanguage: 1590 m.ResetFeedLanguage() 1591 return nil 1592 case feed.FieldFeedImageTitle: 1593 m.ResetFeedImageTitle() 1594 return nil 1595 case feed.FieldFeedImageURL: 1596 m.ResetFeedImageURL() 1597 return nil 1598 case feed.FieldFeedCopyright: 1599 m.ResetFeedCopyright() 1600 return nil 1601 case feed.FieldFeedGenerator: 1602 m.ResetFeedGenerator() 1603 return nil 1604 case feed.FieldFeedCategories: 1605 m.ResetFeedCategories() 1606 return nil 1607 case feed.FieldCreatedAt: 1608 m.ResetCreatedAt() 1609 return nil 1610 case feed.FieldUpdatedAt: 1611 m.ResetUpdatedAt() 1612 return nil 1613 case feed.FieldDeletedAt: 1614 m.ResetDeletedAt() 1615 return nil 1616 } 1617 return fmt.Errorf("unknown Feed field %s", name) 1618 } 1619 1620 // AddedEdges returns all edge names that were set/added in this mutation. 1621 func (m *FeedMutation) AddedEdges() []string { 1622 edges := make([]string, 0, 3) 1623 if m.items != nil { 1624 edges = append(edges, feed.EdgeItems) 1625 } 1626 if m.subscribed_users != nil { 1627 edges = append(edges, feed.EdgeSubscribedUsers) 1628 } 1629 if m.subscriptions != nil { 1630 edges = append(edges, feed.EdgeSubscriptions) 1631 } 1632 return edges 1633 } 1634 1635 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 1636 // name in this mutation. 1637 func (m *FeedMutation) AddedIDs(name string) []ent.Value { 1638 switch name { 1639 case feed.EdgeItems: 1640 ids := make([]ent.Value, 0, len(m.items)) 1641 for id := range m.items { 1642 ids = append(ids, id) 1643 } 1644 return ids 1645 case feed.EdgeSubscribedUsers: 1646 ids := make([]ent.Value, 0, len(m.subscribed_users)) 1647 for id := range m.subscribed_users { 1648 ids = append(ids, id) 1649 } 1650 return ids 1651 case feed.EdgeSubscriptions: 1652 ids := make([]ent.Value, 0, len(m.subscriptions)) 1653 for id := range m.subscriptions { 1654 ids = append(ids, id) 1655 } 1656 return ids 1657 } 1658 return nil 1659 } 1660 1661 // RemovedEdges returns all edge names that were removed in this mutation. 1662 func (m *FeedMutation) RemovedEdges() []string { 1663 edges := make([]string, 0, 3) 1664 if m.removeditems != nil { 1665 edges = append(edges, feed.EdgeItems) 1666 } 1667 if m.removedsubscribed_users != nil { 1668 edges = append(edges, feed.EdgeSubscribedUsers) 1669 } 1670 if m.removedsubscriptions != nil { 1671 edges = append(edges, feed.EdgeSubscriptions) 1672 } 1673 return edges 1674 } 1675 1676 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 1677 // the given name in this mutation. 1678 func (m *FeedMutation) RemovedIDs(name string) []ent.Value { 1679 switch name { 1680 case feed.EdgeItems: 1681 ids := make([]ent.Value, 0, len(m.removeditems)) 1682 for id := range m.removeditems { 1683 ids = append(ids, id) 1684 } 1685 return ids 1686 case feed.EdgeSubscribedUsers: 1687 ids := make([]ent.Value, 0, len(m.removedsubscribed_users)) 1688 for id := range m.removedsubscribed_users { 1689 ids = append(ids, id) 1690 } 1691 return ids 1692 case feed.EdgeSubscriptions: 1693 ids := make([]ent.Value, 0, len(m.removedsubscriptions)) 1694 for id := range m.removedsubscriptions { 1695 ids = append(ids, id) 1696 } 1697 return ids 1698 } 1699 return nil 1700 } 1701 1702 // ClearedEdges returns all edge names that were cleared in this mutation. 1703 func (m *FeedMutation) ClearedEdges() []string { 1704 edges := make([]string, 0, 3) 1705 if m.cleareditems { 1706 edges = append(edges, feed.EdgeItems) 1707 } 1708 if m.clearedsubscribed_users { 1709 edges = append(edges, feed.EdgeSubscribedUsers) 1710 } 1711 if m.clearedsubscriptions { 1712 edges = append(edges, feed.EdgeSubscriptions) 1713 } 1714 return edges 1715 } 1716 1717 // EdgeCleared returns a boolean which indicates if the edge with the given name 1718 // was cleared in this mutation. 1719 func (m *FeedMutation) EdgeCleared(name string) bool { 1720 switch name { 1721 case feed.EdgeItems: 1722 return m.cleareditems 1723 case feed.EdgeSubscribedUsers: 1724 return m.clearedsubscribed_users 1725 case feed.EdgeSubscriptions: 1726 return m.clearedsubscriptions 1727 } 1728 return false 1729 } 1730 1731 // ClearEdge clears the value of the edge with the given name. It returns an error 1732 // if that edge is not defined in the schema. 1733 func (m *FeedMutation) ClearEdge(name string) error { 1734 switch name { 1735 } 1736 return fmt.Errorf("unknown Feed unique edge %s", name) 1737 } 1738 1739 // ResetEdge resets all changes to the edge with the given name in this mutation. 1740 // It returns an error if the edge is not defined in the schema. 1741 func (m *FeedMutation) ResetEdge(name string) error { 1742 switch name { 1743 case feed.EdgeItems: 1744 m.ResetItems() 1745 return nil 1746 case feed.EdgeSubscribedUsers: 1747 m.ResetSubscribedUsers() 1748 return nil 1749 case feed.EdgeSubscriptions: 1750 m.ResetSubscriptions() 1751 return nil 1752 } 1753 return fmt.Errorf("unknown Feed edge %s", name) 1754 } 1755 1756 // ItemMutation represents an operation that mutates the Item nodes in the graph. 1757 type ItemMutation struct { 1758 config 1759 op Op 1760 typ string 1761 id *uuid.UUID 1762 item_guid *string 1763 item_title *string 1764 item_description *string 1765 item_content *string 1766 item_link *string 1767 item_updated *time.Time 1768 item_published *time.Time 1769 item_author_name *string 1770 item_author_email *string 1771 item_image_title *string 1772 item_image_url *string 1773 item_categories *string 1774 item_enclosures *string 1775 crawler_title *string 1776 crawler_author *string 1777 crawler_excerpt *string 1778 crawler_site_name *string 1779 crawler_image *string 1780 crawler_content_html *string 1781 crawler_content_text *string 1782 created_at *time.Time 1783 updated_at *time.Time 1784 clearedFields map[string]struct{} 1785 feed *uuid.UUID 1786 clearedfeed bool 1787 read_by_users map[uuid.UUID]struct{} 1788 removedread_by_users map[uuid.UUID]struct{} 1789 clearedread_by_users bool 1790 reads map[uuid.UUID]struct{} 1791 removedreads map[uuid.UUID]struct{} 1792 clearedreads bool 1793 done bool 1794 oldValue func(context.Context) (*Item, error) 1795 predicates []predicate.Item 1796 } 1797 1798 var _ ent.Mutation = (*ItemMutation)(nil) 1799 1800 // itemOption allows management of the mutation configuration using functional options. 1801 type itemOption func(*ItemMutation) 1802 1803 // newItemMutation creates new mutation for the Item entity. 1804 func newItemMutation(c config, op Op, opts ...itemOption) *ItemMutation { 1805 m := &ItemMutation{ 1806 config: c, 1807 op: op, 1808 typ: TypeItem, 1809 clearedFields: make(map[string]struct{}), 1810 } 1811 for _, opt := range opts { 1812 opt(m) 1813 } 1814 return m 1815 } 1816 1817 // withItemID sets the ID field of the mutation. 1818 func withItemID(id uuid.UUID) itemOption { 1819 return func(m *ItemMutation) { 1820 var ( 1821 err error 1822 once sync.Once 1823 value *Item 1824 ) 1825 m.oldValue = func(ctx context.Context) (*Item, error) { 1826 once.Do(func() { 1827 if m.done { 1828 err = errors.New("querying old values post mutation is not allowed") 1829 } else { 1830 value, err = m.Client().Item.Get(ctx, id) 1831 } 1832 }) 1833 return value, err 1834 } 1835 m.id = &id 1836 } 1837 } 1838 1839 // withItem sets the old Item of the mutation. 1840 func withItem(node *Item) itemOption { 1841 return func(m *ItemMutation) { 1842 m.oldValue = func(context.Context) (*Item, error) { 1843 return node, nil 1844 } 1845 m.id = &node.ID 1846 } 1847 } 1848 1849 // Client returns a new `ent.Client` from the mutation. If the mutation was 1850 // executed in a transaction (ent.Tx), a transactional client is returned. 1851 func (m ItemMutation) Client() *Client { 1852 client := &Client{config: m.config} 1853 client.init() 1854 return client 1855 } 1856 1857 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 1858 // it returns an error otherwise. 1859 func (m ItemMutation) Tx() (*Tx, error) { 1860 if _, ok := m.driver.(*txDriver); !ok { 1861 return nil, errors.New("ent: mutation is not running in a transaction") 1862 } 1863 tx := &Tx{config: m.config} 1864 tx.init() 1865 return tx, nil 1866 } 1867 1868 // SetID sets the value of the id field. Note that this 1869 // operation is only accepted on creation of Item entities. 1870 func (m *ItemMutation) SetID(id uuid.UUID) { 1871 m.id = &id 1872 } 1873 1874 // ID returns the ID value in the mutation. Note that the ID is only available 1875 // if it was provided to the builder or after it was returned from the database. 1876 func (m *ItemMutation) ID() (id uuid.UUID, exists bool) { 1877 if m.id == nil { 1878 return 1879 } 1880 return *m.id, true 1881 } 1882 1883 // IDs queries the database and returns the entity ids that match the mutation's predicate. 1884 // That means, if the mutation is applied within a transaction with an isolation level such 1885 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 1886 // or updated by the mutation. 1887 func (m *ItemMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { 1888 switch { 1889 case m.op.Is(OpUpdateOne | OpDeleteOne): 1890 id, exists := m.ID() 1891 if exists { 1892 return []uuid.UUID{id}, nil 1893 } 1894 fallthrough 1895 case m.op.Is(OpUpdate | OpDelete): 1896 return m.Client().Item.Query().Where(m.predicates...).IDs(ctx) 1897 default: 1898 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 1899 } 1900 } 1901 1902 // SetItemGUID sets the "item_guid" field. 1903 func (m *ItemMutation) SetItemGUID(s string) { 1904 m.item_guid = &s 1905 } 1906 1907 // ItemGUID returns the value of the "item_guid" field in the mutation. 1908 func (m *ItemMutation) ItemGUID() (r string, exists bool) { 1909 v := m.item_guid 1910 if v == nil { 1911 return 1912 } 1913 return *v, true 1914 } 1915 1916 // OldItemGUID returns the old "item_guid" field's value of the Item entity. 1917 // If the Item object wasn't provided to the builder, the object is fetched from the database. 1918 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 1919 func (m *ItemMutation) OldItemGUID(ctx context.Context) (v string, err error) { 1920 if !m.op.Is(OpUpdateOne) { 1921 return v, errors.New("OldItemGUID is only allowed on UpdateOne operations") 1922 } 1923 if m.id == nil || m.oldValue == nil { 1924 return v, errors.New("OldItemGUID requires an ID field in the mutation") 1925 } 1926 oldValue, err := m.oldValue(ctx) 1927 if err != nil { 1928 return v, fmt.Errorf("querying old value for OldItemGUID: %w", err) 1929 } 1930 return oldValue.ItemGUID, nil 1931 } 1932 1933 // ResetItemGUID resets all changes to the "item_guid" field. 1934 func (m *ItemMutation) ResetItemGUID() { 1935 m.item_guid = nil 1936 } 1937 1938 // SetItemTitle sets the "item_title" field. 1939 func (m *ItemMutation) SetItemTitle(s string) { 1940 m.item_title = &s 1941 } 1942 1943 // ItemTitle returns the value of the "item_title" field in the mutation. 1944 func (m *ItemMutation) ItemTitle() (r string, exists bool) { 1945 v := m.item_title 1946 if v == nil { 1947 return 1948 } 1949 return *v, true 1950 } 1951 1952 // OldItemTitle returns the old "item_title" field's value of the Item entity. 1953 // If the Item object wasn't provided to the builder, the object is fetched from the database. 1954 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 1955 func (m *ItemMutation) OldItemTitle(ctx context.Context) (v string, err error) { 1956 if !m.op.Is(OpUpdateOne) { 1957 return v, errors.New("OldItemTitle is only allowed on UpdateOne operations") 1958 } 1959 if m.id == nil || m.oldValue == nil { 1960 return v, errors.New("OldItemTitle requires an ID field in the mutation") 1961 } 1962 oldValue, err := m.oldValue(ctx) 1963 if err != nil { 1964 return v, fmt.Errorf("querying old value for OldItemTitle: %w", err) 1965 } 1966 return oldValue.ItemTitle, nil 1967 } 1968 1969 // ResetItemTitle resets all changes to the "item_title" field. 1970 func (m *ItemMutation) ResetItemTitle() { 1971 m.item_title = nil 1972 } 1973 1974 // SetItemDescription sets the "item_description" field. 1975 func (m *ItemMutation) SetItemDescription(s string) { 1976 m.item_description = &s 1977 } 1978 1979 // ItemDescription returns the value of the "item_description" field in the mutation. 1980 func (m *ItemMutation) ItemDescription() (r string, exists bool) { 1981 v := m.item_description 1982 if v == nil { 1983 return 1984 } 1985 return *v, true 1986 } 1987 1988 // OldItemDescription returns the old "item_description" field's value of the Item entity. 1989 // If the Item object wasn't provided to the builder, the object is fetched from the database. 1990 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 1991 func (m *ItemMutation) OldItemDescription(ctx context.Context) (v string, err error) { 1992 if !m.op.Is(OpUpdateOne) { 1993 return v, errors.New("OldItemDescription is only allowed on UpdateOne operations") 1994 } 1995 if m.id == nil || m.oldValue == nil { 1996 return v, errors.New("OldItemDescription requires an ID field in the mutation") 1997 } 1998 oldValue, err := m.oldValue(ctx) 1999 if err != nil { 2000 return v, fmt.Errorf("querying old value for OldItemDescription: %w", err) 2001 } 2002 return oldValue.ItemDescription, nil 2003 } 2004 2005 // ResetItemDescription resets all changes to the "item_description" field. 2006 func (m *ItemMutation) ResetItemDescription() { 2007 m.item_description = nil 2008 } 2009 2010 // SetItemContent sets the "item_content" field. 2011 func (m *ItemMutation) SetItemContent(s string) { 2012 m.item_content = &s 2013 } 2014 2015 // ItemContent returns the value of the "item_content" field in the mutation. 2016 func (m *ItemMutation) ItemContent() (r string, exists bool) { 2017 v := m.item_content 2018 if v == nil { 2019 return 2020 } 2021 return *v, true 2022 } 2023 2024 // OldItemContent returns the old "item_content" field's value of the Item entity. 2025 // If the Item object wasn't provided to the builder, the object is fetched from the database. 2026 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2027 func (m *ItemMutation) OldItemContent(ctx context.Context) (v string, err error) { 2028 if !m.op.Is(OpUpdateOne) { 2029 return v, errors.New("OldItemContent is only allowed on UpdateOne operations") 2030 } 2031 if m.id == nil || m.oldValue == nil { 2032 return v, errors.New("OldItemContent requires an ID field in the mutation") 2033 } 2034 oldValue, err := m.oldValue(ctx) 2035 if err != nil { 2036 return v, fmt.Errorf("querying old value for OldItemContent: %w", err) 2037 } 2038 return oldValue.ItemContent, nil 2039 } 2040 2041 // ResetItemContent resets all changes to the "item_content" field. 2042 func (m *ItemMutation) ResetItemContent() { 2043 m.item_content = nil 2044 } 2045 2046 // SetItemLink sets the "item_link" field. 2047 func (m *ItemMutation) SetItemLink(s string) { 2048 m.item_link = &s 2049 } 2050 2051 // ItemLink returns the value of the "item_link" field in the mutation. 2052 func (m *ItemMutation) ItemLink() (r string, exists bool) { 2053 v := m.item_link 2054 if v == nil { 2055 return 2056 } 2057 return *v, true 2058 } 2059 2060 // OldItemLink returns the old "item_link" field's value of the Item entity. 2061 // If the Item object wasn't provided to the builder, the object is fetched from the database. 2062 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2063 func (m *ItemMutation) OldItemLink(ctx context.Context) (v string, err error) { 2064 if !m.op.Is(OpUpdateOne) { 2065 return v, errors.New("OldItemLink is only allowed on UpdateOne operations") 2066 } 2067 if m.id == nil || m.oldValue == nil { 2068 return v, errors.New("OldItemLink requires an ID field in the mutation") 2069 } 2070 oldValue, err := m.oldValue(ctx) 2071 if err != nil { 2072 return v, fmt.Errorf("querying old value for OldItemLink: %w", err) 2073 } 2074 return oldValue.ItemLink, nil 2075 } 2076 2077 // ResetItemLink resets all changes to the "item_link" field. 2078 func (m *ItemMutation) ResetItemLink() { 2079 m.item_link = nil 2080 } 2081 2082 // SetItemUpdated sets the "item_updated" field. 2083 func (m *ItemMutation) SetItemUpdated(t time.Time) { 2084 m.item_updated = &t 2085 } 2086 2087 // ItemUpdated returns the value of the "item_updated" field in the mutation. 2088 func (m *ItemMutation) ItemUpdated() (r time.Time, exists bool) { 2089 v := m.item_updated 2090 if v == nil { 2091 return 2092 } 2093 return *v, true 2094 } 2095 2096 // OldItemUpdated returns the old "item_updated" field's value of the Item entity. 2097 // If the Item object wasn't provided to the builder, the object is fetched from the database. 2098 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2099 func (m *ItemMutation) OldItemUpdated(ctx context.Context) (v time.Time, err error) { 2100 if !m.op.Is(OpUpdateOne) { 2101 return v, errors.New("OldItemUpdated is only allowed on UpdateOne operations") 2102 } 2103 if m.id == nil || m.oldValue == nil { 2104 return v, errors.New("OldItemUpdated requires an ID field in the mutation") 2105 } 2106 oldValue, err := m.oldValue(ctx) 2107 if err != nil { 2108 return v, fmt.Errorf("querying old value for OldItemUpdated: %w", err) 2109 } 2110 return oldValue.ItemUpdated, nil 2111 } 2112 2113 // ResetItemUpdated resets all changes to the "item_updated" field. 2114 func (m *ItemMutation) ResetItemUpdated() { 2115 m.item_updated = nil 2116 } 2117 2118 // SetItemPublished sets the "item_published" field. 2119 func (m *ItemMutation) SetItemPublished(t time.Time) { 2120 m.item_published = &t 2121 } 2122 2123 // ItemPublished returns the value of the "item_published" field in the mutation. 2124 func (m *ItemMutation) ItemPublished() (r time.Time, exists bool) { 2125 v := m.item_published 2126 if v == nil { 2127 return 2128 } 2129 return *v, true 2130 } 2131 2132 // OldItemPublished returns the old "item_published" field's value of the Item entity. 2133 // If the Item object wasn't provided to the builder, the object is fetched from the database. 2134 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2135 func (m *ItemMutation) OldItemPublished(ctx context.Context) (v time.Time, err error) { 2136 if !m.op.Is(OpUpdateOne) { 2137 return v, errors.New("OldItemPublished is only allowed on UpdateOne operations") 2138 } 2139 if m.id == nil || m.oldValue == nil { 2140 return v, errors.New("OldItemPublished requires an ID field in the mutation") 2141 } 2142 oldValue, err := m.oldValue(ctx) 2143 if err != nil { 2144 return v, fmt.Errorf("querying old value for OldItemPublished: %w", err) 2145 } 2146 return oldValue.ItemPublished, nil 2147 } 2148 2149 // ResetItemPublished resets all changes to the "item_published" field. 2150 func (m *ItemMutation) ResetItemPublished() { 2151 m.item_published = nil 2152 } 2153 2154 // SetItemAuthorName sets the "item_author_name" field. 2155 func (m *ItemMutation) SetItemAuthorName(s string) { 2156 m.item_author_name = &s 2157 } 2158 2159 // ItemAuthorName returns the value of the "item_author_name" field in the mutation. 2160 func (m *ItemMutation) ItemAuthorName() (r string, exists bool) { 2161 v := m.item_author_name 2162 if v == nil { 2163 return 2164 } 2165 return *v, true 2166 } 2167 2168 // OldItemAuthorName returns the old "item_author_name" field's value of the Item entity. 2169 // If the Item object wasn't provided to the builder, the object is fetched from the database. 2170 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2171 func (m *ItemMutation) OldItemAuthorName(ctx context.Context) (v string, err error) { 2172 if !m.op.Is(OpUpdateOne) { 2173 return v, errors.New("OldItemAuthorName is only allowed on UpdateOne operations") 2174 } 2175 if m.id == nil || m.oldValue == nil { 2176 return v, errors.New("OldItemAuthorName requires an ID field in the mutation") 2177 } 2178 oldValue, err := m.oldValue(ctx) 2179 if err != nil { 2180 return v, fmt.Errorf("querying old value for OldItemAuthorName: %w", err) 2181 } 2182 return oldValue.ItemAuthorName, nil 2183 } 2184 2185 // ClearItemAuthorName clears the value of the "item_author_name" field. 2186 func (m *ItemMutation) ClearItemAuthorName() { 2187 m.item_author_name = nil 2188 m.clearedFields[item.FieldItemAuthorName] = struct{}{} 2189 } 2190 2191 // ItemAuthorNameCleared returns if the "item_author_name" field was cleared in this mutation. 2192 func (m *ItemMutation) ItemAuthorNameCleared() bool { 2193 _, ok := m.clearedFields[item.FieldItemAuthorName] 2194 return ok 2195 } 2196 2197 // ResetItemAuthorName resets all changes to the "item_author_name" field. 2198 func (m *ItemMutation) ResetItemAuthorName() { 2199 m.item_author_name = nil 2200 delete(m.clearedFields, item.FieldItemAuthorName) 2201 } 2202 2203 // SetItemAuthorEmail sets the "item_author_email" field. 2204 func (m *ItemMutation) SetItemAuthorEmail(s string) { 2205 m.item_author_email = &s 2206 } 2207 2208 // ItemAuthorEmail returns the value of the "item_author_email" field in the mutation. 2209 func (m *ItemMutation) ItemAuthorEmail() (r string, exists bool) { 2210 v := m.item_author_email 2211 if v == nil { 2212 return 2213 } 2214 return *v, true 2215 } 2216 2217 // OldItemAuthorEmail returns the old "item_author_email" field's value of the Item entity. 2218 // If the Item object wasn't provided to the builder, the object is fetched from the database. 2219 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2220 func (m *ItemMutation) OldItemAuthorEmail(ctx context.Context) (v string, err error) { 2221 if !m.op.Is(OpUpdateOne) { 2222 return v, errors.New("OldItemAuthorEmail is only allowed on UpdateOne operations") 2223 } 2224 if m.id == nil || m.oldValue == nil { 2225 return v, errors.New("OldItemAuthorEmail requires an ID field in the mutation") 2226 } 2227 oldValue, err := m.oldValue(ctx) 2228 if err != nil { 2229 return v, fmt.Errorf("querying old value for OldItemAuthorEmail: %w", err) 2230 } 2231 return oldValue.ItemAuthorEmail, nil 2232 } 2233 2234 // ClearItemAuthorEmail clears the value of the "item_author_email" field. 2235 func (m *ItemMutation) ClearItemAuthorEmail() { 2236 m.item_author_email = nil 2237 m.clearedFields[item.FieldItemAuthorEmail] = struct{}{} 2238 } 2239 2240 // ItemAuthorEmailCleared returns if the "item_author_email" field was cleared in this mutation. 2241 func (m *ItemMutation) ItemAuthorEmailCleared() bool { 2242 _, ok := m.clearedFields[item.FieldItemAuthorEmail] 2243 return ok 2244 } 2245 2246 // ResetItemAuthorEmail resets all changes to the "item_author_email" field. 2247 func (m *ItemMutation) ResetItemAuthorEmail() { 2248 m.item_author_email = nil 2249 delete(m.clearedFields, item.FieldItemAuthorEmail) 2250 } 2251 2252 // SetItemImageTitle sets the "item_image_title" field. 2253 func (m *ItemMutation) SetItemImageTitle(s string) { 2254 m.item_image_title = &s 2255 } 2256 2257 // ItemImageTitle returns the value of the "item_image_title" field in the mutation. 2258 func (m *ItemMutation) ItemImageTitle() (r string, exists bool) { 2259 v := m.item_image_title 2260 if v == nil { 2261 return 2262 } 2263 return *v, true 2264 } 2265 2266 // OldItemImageTitle returns the old "item_image_title" field's value of the Item entity. 2267 // If the Item object wasn't provided to the builder, the object is fetched from the database. 2268 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2269 func (m *ItemMutation) OldItemImageTitle(ctx context.Context) (v string, err error) { 2270 if !m.op.Is(OpUpdateOne) { 2271 return v, errors.New("OldItemImageTitle is only allowed on UpdateOne operations") 2272 } 2273 if m.id == nil || m.oldValue == nil { 2274 return v, errors.New("OldItemImageTitle requires an ID field in the mutation") 2275 } 2276 oldValue, err := m.oldValue(ctx) 2277 if err != nil { 2278 return v, fmt.Errorf("querying old value for OldItemImageTitle: %w", err) 2279 } 2280 return oldValue.ItemImageTitle, nil 2281 } 2282 2283 // ClearItemImageTitle clears the value of the "item_image_title" field. 2284 func (m *ItemMutation) ClearItemImageTitle() { 2285 m.item_image_title = nil 2286 m.clearedFields[item.FieldItemImageTitle] = struct{}{} 2287 } 2288 2289 // ItemImageTitleCleared returns if the "item_image_title" field was cleared in this mutation. 2290 func (m *ItemMutation) ItemImageTitleCleared() bool { 2291 _, ok := m.clearedFields[item.FieldItemImageTitle] 2292 return ok 2293 } 2294 2295 // ResetItemImageTitle resets all changes to the "item_image_title" field. 2296 func (m *ItemMutation) ResetItemImageTitle() { 2297 m.item_image_title = nil 2298 delete(m.clearedFields, item.FieldItemImageTitle) 2299 } 2300 2301 // SetItemImageURL sets the "item_image_url" field. 2302 func (m *ItemMutation) SetItemImageURL(s string) { 2303 m.item_image_url = &s 2304 } 2305 2306 // ItemImageURL returns the value of the "item_image_url" field in the mutation. 2307 func (m *ItemMutation) ItemImageURL() (r string, exists bool) { 2308 v := m.item_image_url 2309 if v == nil { 2310 return 2311 } 2312 return *v, true 2313 } 2314 2315 // OldItemImageURL returns the old "item_image_url" field's value of the Item entity. 2316 // If the Item object wasn't provided to the builder, the object is fetched from the database. 2317 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2318 func (m *ItemMutation) OldItemImageURL(ctx context.Context) (v string, err error) { 2319 if !m.op.Is(OpUpdateOne) { 2320 return v, errors.New("OldItemImageURL is only allowed on UpdateOne operations") 2321 } 2322 if m.id == nil || m.oldValue == nil { 2323 return v, errors.New("OldItemImageURL requires an ID field in the mutation") 2324 } 2325 oldValue, err := m.oldValue(ctx) 2326 if err != nil { 2327 return v, fmt.Errorf("querying old value for OldItemImageURL: %w", err) 2328 } 2329 return oldValue.ItemImageURL, nil 2330 } 2331 2332 // ClearItemImageURL clears the value of the "item_image_url" field. 2333 func (m *ItemMutation) ClearItemImageURL() { 2334 m.item_image_url = nil 2335 m.clearedFields[item.FieldItemImageURL] = struct{}{} 2336 } 2337 2338 // ItemImageURLCleared returns if the "item_image_url" field was cleared in this mutation. 2339 func (m *ItemMutation) ItemImageURLCleared() bool { 2340 _, ok := m.clearedFields[item.FieldItemImageURL] 2341 return ok 2342 } 2343 2344 // ResetItemImageURL resets all changes to the "item_image_url" field. 2345 func (m *ItemMutation) ResetItemImageURL() { 2346 m.item_image_url = nil 2347 delete(m.clearedFields, item.FieldItemImageURL) 2348 } 2349 2350 // SetItemCategories sets the "item_categories" field. 2351 func (m *ItemMutation) SetItemCategories(s string) { 2352 m.item_categories = &s 2353 } 2354 2355 // ItemCategories returns the value of the "item_categories" field in the mutation. 2356 func (m *ItemMutation) ItemCategories() (r string, exists bool) { 2357 v := m.item_categories 2358 if v == nil { 2359 return 2360 } 2361 return *v, true 2362 } 2363 2364 // OldItemCategories returns the old "item_categories" field's value of the Item entity. 2365 // If the Item object wasn't provided to the builder, the object is fetched from the database. 2366 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2367 func (m *ItemMutation) OldItemCategories(ctx context.Context) (v string, err error) { 2368 if !m.op.Is(OpUpdateOne) { 2369 return v, errors.New("OldItemCategories is only allowed on UpdateOne operations") 2370 } 2371 if m.id == nil || m.oldValue == nil { 2372 return v, errors.New("OldItemCategories requires an ID field in the mutation") 2373 } 2374 oldValue, err := m.oldValue(ctx) 2375 if err != nil { 2376 return v, fmt.Errorf("querying old value for OldItemCategories: %w", err) 2377 } 2378 return oldValue.ItemCategories, nil 2379 } 2380 2381 // ResetItemCategories resets all changes to the "item_categories" field. 2382 func (m *ItemMutation) ResetItemCategories() { 2383 m.item_categories = nil 2384 } 2385 2386 // SetItemEnclosures sets the "item_enclosures" field. 2387 func (m *ItemMutation) SetItemEnclosures(s string) { 2388 m.item_enclosures = &s 2389 } 2390 2391 // ItemEnclosures returns the value of the "item_enclosures" field in the mutation. 2392 func (m *ItemMutation) ItemEnclosures() (r string, exists bool) { 2393 v := m.item_enclosures 2394 if v == nil { 2395 return 2396 } 2397 return *v, true 2398 } 2399 2400 // OldItemEnclosures returns the old "item_enclosures" field's value of the Item entity. 2401 // If the Item object wasn't provided to the builder, the object is fetched from the database. 2402 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2403 func (m *ItemMutation) OldItemEnclosures(ctx context.Context) (v string, err error) { 2404 if !m.op.Is(OpUpdateOne) { 2405 return v, errors.New("OldItemEnclosures is only allowed on UpdateOne operations") 2406 } 2407 if m.id == nil || m.oldValue == nil { 2408 return v, errors.New("OldItemEnclosures requires an ID field in the mutation") 2409 } 2410 oldValue, err := m.oldValue(ctx) 2411 if err != nil { 2412 return v, fmt.Errorf("querying old value for OldItemEnclosures: %w", err) 2413 } 2414 return oldValue.ItemEnclosures, nil 2415 } 2416 2417 // ResetItemEnclosures resets all changes to the "item_enclosures" field. 2418 func (m *ItemMutation) ResetItemEnclosures() { 2419 m.item_enclosures = nil 2420 } 2421 2422 // SetCrawlerTitle sets the "crawler_title" field. 2423 func (m *ItemMutation) SetCrawlerTitle(s string) { 2424 m.crawler_title = &s 2425 } 2426 2427 // CrawlerTitle returns the value of the "crawler_title" field in the mutation. 2428 func (m *ItemMutation) CrawlerTitle() (r string, exists bool) { 2429 v := m.crawler_title 2430 if v == nil { 2431 return 2432 } 2433 return *v, true 2434 } 2435 2436 // OldCrawlerTitle returns the old "crawler_title" field's value of the Item entity. 2437 // If the Item object wasn't provided to the builder, the object is fetched from the database. 2438 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2439 func (m *ItemMutation) OldCrawlerTitle(ctx context.Context) (v string, err error) { 2440 if !m.op.Is(OpUpdateOne) { 2441 return v, errors.New("OldCrawlerTitle is only allowed on UpdateOne operations") 2442 } 2443 if m.id == nil || m.oldValue == nil { 2444 return v, errors.New("OldCrawlerTitle requires an ID field in the mutation") 2445 } 2446 oldValue, err := m.oldValue(ctx) 2447 if err != nil { 2448 return v, fmt.Errorf("querying old value for OldCrawlerTitle: %w", err) 2449 } 2450 return oldValue.CrawlerTitle, nil 2451 } 2452 2453 // ClearCrawlerTitle clears the value of the "crawler_title" field. 2454 func (m *ItemMutation) ClearCrawlerTitle() { 2455 m.crawler_title = nil 2456 m.clearedFields[item.FieldCrawlerTitle] = struct{}{} 2457 } 2458 2459 // CrawlerTitleCleared returns if the "crawler_title" field was cleared in this mutation. 2460 func (m *ItemMutation) CrawlerTitleCleared() bool { 2461 _, ok := m.clearedFields[item.FieldCrawlerTitle] 2462 return ok 2463 } 2464 2465 // ResetCrawlerTitle resets all changes to the "crawler_title" field. 2466 func (m *ItemMutation) ResetCrawlerTitle() { 2467 m.crawler_title = nil 2468 delete(m.clearedFields, item.FieldCrawlerTitle) 2469 } 2470 2471 // SetCrawlerAuthor sets the "crawler_author" field. 2472 func (m *ItemMutation) SetCrawlerAuthor(s string) { 2473 m.crawler_author = &s 2474 } 2475 2476 // CrawlerAuthor returns the value of the "crawler_author" field in the mutation. 2477 func (m *ItemMutation) CrawlerAuthor() (r string, exists bool) { 2478 v := m.crawler_author 2479 if v == nil { 2480 return 2481 } 2482 return *v, true 2483 } 2484 2485 // OldCrawlerAuthor returns the old "crawler_author" field's value of the Item entity. 2486 // If the Item object wasn't provided to the builder, the object is fetched from the database. 2487 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2488 func (m *ItemMutation) OldCrawlerAuthor(ctx context.Context) (v string, err error) { 2489 if !m.op.Is(OpUpdateOne) { 2490 return v, errors.New("OldCrawlerAuthor is only allowed on UpdateOne operations") 2491 } 2492 if m.id == nil || m.oldValue == nil { 2493 return v, errors.New("OldCrawlerAuthor requires an ID field in the mutation") 2494 } 2495 oldValue, err := m.oldValue(ctx) 2496 if err != nil { 2497 return v, fmt.Errorf("querying old value for OldCrawlerAuthor: %w", err) 2498 } 2499 return oldValue.CrawlerAuthor, nil 2500 } 2501 2502 // ClearCrawlerAuthor clears the value of the "crawler_author" field. 2503 func (m *ItemMutation) ClearCrawlerAuthor() { 2504 m.crawler_author = nil 2505 m.clearedFields[item.FieldCrawlerAuthor] = struct{}{} 2506 } 2507 2508 // CrawlerAuthorCleared returns if the "crawler_author" field was cleared in this mutation. 2509 func (m *ItemMutation) CrawlerAuthorCleared() bool { 2510 _, ok := m.clearedFields[item.FieldCrawlerAuthor] 2511 return ok 2512 } 2513 2514 // ResetCrawlerAuthor resets all changes to the "crawler_author" field. 2515 func (m *ItemMutation) ResetCrawlerAuthor() { 2516 m.crawler_author = nil 2517 delete(m.clearedFields, item.FieldCrawlerAuthor) 2518 } 2519 2520 // SetCrawlerExcerpt sets the "crawler_excerpt" field. 2521 func (m *ItemMutation) SetCrawlerExcerpt(s string) { 2522 m.crawler_excerpt = &s 2523 } 2524 2525 // CrawlerExcerpt returns the value of the "crawler_excerpt" field in the mutation. 2526 func (m *ItemMutation) CrawlerExcerpt() (r string, exists bool) { 2527 v := m.crawler_excerpt 2528 if v == nil { 2529 return 2530 } 2531 return *v, true 2532 } 2533 2534 // OldCrawlerExcerpt returns the old "crawler_excerpt" field's value of the Item entity. 2535 // If the Item object wasn't provided to the builder, the object is fetched from the database. 2536 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2537 func (m *ItemMutation) OldCrawlerExcerpt(ctx context.Context) (v string, err error) { 2538 if !m.op.Is(OpUpdateOne) { 2539 return v, errors.New("OldCrawlerExcerpt is only allowed on UpdateOne operations") 2540 } 2541 if m.id == nil || m.oldValue == nil { 2542 return v, errors.New("OldCrawlerExcerpt requires an ID field in the mutation") 2543 } 2544 oldValue, err := m.oldValue(ctx) 2545 if err != nil { 2546 return v, fmt.Errorf("querying old value for OldCrawlerExcerpt: %w", err) 2547 } 2548 return oldValue.CrawlerExcerpt, nil 2549 } 2550 2551 // ClearCrawlerExcerpt clears the value of the "crawler_excerpt" field. 2552 func (m *ItemMutation) ClearCrawlerExcerpt() { 2553 m.crawler_excerpt = nil 2554 m.clearedFields[item.FieldCrawlerExcerpt] = struct{}{} 2555 } 2556 2557 // CrawlerExcerptCleared returns if the "crawler_excerpt" field was cleared in this mutation. 2558 func (m *ItemMutation) CrawlerExcerptCleared() bool { 2559 _, ok := m.clearedFields[item.FieldCrawlerExcerpt] 2560 return ok 2561 } 2562 2563 // ResetCrawlerExcerpt resets all changes to the "crawler_excerpt" field. 2564 func (m *ItemMutation) ResetCrawlerExcerpt() { 2565 m.crawler_excerpt = nil 2566 delete(m.clearedFields, item.FieldCrawlerExcerpt) 2567 } 2568 2569 // SetCrawlerSiteName sets the "crawler_site_name" field. 2570 func (m *ItemMutation) SetCrawlerSiteName(s string) { 2571 m.crawler_site_name = &s 2572 } 2573 2574 // CrawlerSiteName returns the value of the "crawler_site_name" field in the mutation. 2575 func (m *ItemMutation) CrawlerSiteName() (r string, exists bool) { 2576 v := m.crawler_site_name 2577 if v == nil { 2578 return 2579 } 2580 return *v, true 2581 } 2582 2583 // OldCrawlerSiteName returns the old "crawler_site_name" field's value of the Item entity. 2584 // If the Item object wasn't provided to the builder, the object is fetched from the database. 2585 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2586 func (m *ItemMutation) OldCrawlerSiteName(ctx context.Context) (v string, err error) { 2587 if !m.op.Is(OpUpdateOne) { 2588 return v, errors.New("OldCrawlerSiteName is only allowed on UpdateOne operations") 2589 } 2590 if m.id == nil || m.oldValue == nil { 2591 return v, errors.New("OldCrawlerSiteName requires an ID field in the mutation") 2592 } 2593 oldValue, err := m.oldValue(ctx) 2594 if err != nil { 2595 return v, fmt.Errorf("querying old value for OldCrawlerSiteName: %w", err) 2596 } 2597 return oldValue.CrawlerSiteName, nil 2598 } 2599 2600 // ClearCrawlerSiteName clears the value of the "crawler_site_name" field. 2601 func (m *ItemMutation) ClearCrawlerSiteName() { 2602 m.crawler_site_name = nil 2603 m.clearedFields[item.FieldCrawlerSiteName] = struct{}{} 2604 } 2605 2606 // CrawlerSiteNameCleared returns if the "crawler_site_name" field was cleared in this mutation. 2607 func (m *ItemMutation) CrawlerSiteNameCleared() bool { 2608 _, ok := m.clearedFields[item.FieldCrawlerSiteName] 2609 return ok 2610 } 2611 2612 // ResetCrawlerSiteName resets all changes to the "crawler_site_name" field. 2613 func (m *ItemMutation) ResetCrawlerSiteName() { 2614 m.crawler_site_name = nil 2615 delete(m.clearedFields, item.FieldCrawlerSiteName) 2616 } 2617 2618 // SetCrawlerImage sets the "crawler_image" field. 2619 func (m *ItemMutation) SetCrawlerImage(s string) { 2620 m.crawler_image = &s 2621 } 2622 2623 // CrawlerImage returns the value of the "crawler_image" field in the mutation. 2624 func (m *ItemMutation) CrawlerImage() (r string, exists bool) { 2625 v := m.crawler_image 2626 if v == nil { 2627 return 2628 } 2629 return *v, true 2630 } 2631 2632 // OldCrawlerImage returns the old "crawler_image" field's value of the Item entity. 2633 // If the Item object wasn't provided to the builder, the object is fetched from the database. 2634 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2635 func (m *ItemMutation) OldCrawlerImage(ctx context.Context) (v string, err error) { 2636 if !m.op.Is(OpUpdateOne) { 2637 return v, errors.New("OldCrawlerImage is only allowed on UpdateOne operations") 2638 } 2639 if m.id == nil || m.oldValue == nil { 2640 return v, errors.New("OldCrawlerImage requires an ID field in the mutation") 2641 } 2642 oldValue, err := m.oldValue(ctx) 2643 if err != nil { 2644 return v, fmt.Errorf("querying old value for OldCrawlerImage: %w", err) 2645 } 2646 return oldValue.CrawlerImage, nil 2647 } 2648 2649 // ClearCrawlerImage clears the value of the "crawler_image" field. 2650 func (m *ItemMutation) ClearCrawlerImage() { 2651 m.crawler_image = nil 2652 m.clearedFields[item.FieldCrawlerImage] = struct{}{} 2653 } 2654 2655 // CrawlerImageCleared returns if the "crawler_image" field was cleared in this mutation. 2656 func (m *ItemMutation) CrawlerImageCleared() bool { 2657 _, ok := m.clearedFields[item.FieldCrawlerImage] 2658 return ok 2659 } 2660 2661 // ResetCrawlerImage resets all changes to the "crawler_image" field. 2662 func (m *ItemMutation) ResetCrawlerImage() { 2663 m.crawler_image = nil 2664 delete(m.clearedFields, item.FieldCrawlerImage) 2665 } 2666 2667 // SetCrawlerContentHTML sets the "crawler_content_html" field. 2668 func (m *ItemMutation) SetCrawlerContentHTML(s string) { 2669 m.crawler_content_html = &s 2670 } 2671 2672 // CrawlerContentHTML returns the value of the "crawler_content_html" field in the mutation. 2673 func (m *ItemMutation) CrawlerContentHTML() (r string, exists bool) { 2674 v := m.crawler_content_html 2675 if v == nil { 2676 return 2677 } 2678 return *v, true 2679 } 2680 2681 // OldCrawlerContentHTML returns the old "crawler_content_html" field's value of the Item entity. 2682 // If the Item object wasn't provided to the builder, the object is fetched from the database. 2683 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2684 func (m *ItemMutation) OldCrawlerContentHTML(ctx context.Context) (v string, err error) { 2685 if !m.op.Is(OpUpdateOne) { 2686 return v, errors.New("OldCrawlerContentHTML is only allowed on UpdateOne operations") 2687 } 2688 if m.id == nil || m.oldValue == nil { 2689 return v, errors.New("OldCrawlerContentHTML requires an ID field in the mutation") 2690 } 2691 oldValue, err := m.oldValue(ctx) 2692 if err != nil { 2693 return v, fmt.Errorf("querying old value for OldCrawlerContentHTML: %w", err) 2694 } 2695 return oldValue.CrawlerContentHTML, nil 2696 } 2697 2698 // ClearCrawlerContentHTML clears the value of the "crawler_content_html" field. 2699 func (m *ItemMutation) ClearCrawlerContentHTML() { 2700 m.crawler_content_html = nil 2701 m.clearedFields[item.FieldCrawlerContentHTML] = struct{}{} 2702 } 2703 2704 // CrawlerContentHTMLCleared returns if the "crawler_content_html" field was cleared in this mutation. 2705 func (m *ItemMutation) CrawlerContentHTMLCleared() bool { 2706 _, ok := m.clearedFields[item.FieldCrawlerContentHTML] 2707 return ok 2708 } 2709 2710 // ResetCrawlerContentHTML resets all changes to the "crawler_content_html" field. 2711 func (m *ItemMutation) ResetCrawlerContentHTML() { 2712 m.crawler_content_html = nil 2713 delete(m.clearedFields, item.FieldCrawlerContentHTML) 2714 } 2715 2716 // SetCrawlerContentText sets the "crawler_content_text" field. 2717 func (m *ItemMutation) SetCrawlerContentText(s string) { 2718 m.crawler_content_text = &s 2719 } 2720 2721 // CrawlerContentText returns the value of the "crawler_content_text" field in the mutation. 2722 func (m *ItemMutation) CrawlerContentText() (r string, exists bool) { 2723 v := m.crawler_content_text 2724 if v == nil { 2725 return 2726 } 2727 return *v, true 2728 } 2729 2730 // OldCrawlerContentText returns the old "crawler_content_text" field's value of the Item entity. 2731 // If the Item object wasn't provided to the builder, the object is fetched from the database. 2732 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2733 func (m *ItemMutation) OldCrawlerContentText(ctx context.Context) (v string, err error) { 2734 if !m.op.Is(OpUpdateOne) { 2735 return v, errors.New("OldCrawlerContentText is only allowed on UpdateOne operations") 2736 } 2737 if m.id == nil || m.oldValue == nil { 2738 return v, errors.New("OldCrawlerContentText requires an ID field in the mutation") 2739 } 2740 oldValue, err := m.oldValue(ctx) 2741 if err != nil { 2742 return v, fmt.Errorf("querying old value for OldCrawlerContentText: %w", err) 2743 } 2744 return oldValue.CrawlerContentText, nil 2745 } 2746 2747 // ClearCrawlerContentText clears the value of the "crawler_content_text" field. 2748 func (m *ItemMutation) ClearCrawlerContentText() { 2749 m.crawler_content_text = nil 2750 m.clearedFields[item.FieldCrawlerContentText] = struct{}{} 2751 } 2752 2753 // CrawlerContentTextCleared returns if the "crawler_content_text" field was cleared in this mutation. 2754 func (m *ItemMutation) CrawlerContentTextCleared() bool { 2755 _, ok := m.clearedFields[item.FieldCrawlerContentText] 2756 return ok 2757 } 2758 2759 // ResetCrawlerContentText resets all changes to the "crawler_content_text" field. 2760 func (m *ItemMutation) ResetCrawlerContentText() { 2761 m.crawler_content_text = nil 2762 delete(m.clearedFields, item.FieldCrawlerContentText) 2763 } 2764 2765 // SetCreatedAt sets the "created_at" field. 2766 func (m *ItemMutation) SetCreatedAt(t time.Time) { 2767 m.created_at = &t 2768 } 2769 2770 // CreatedAt returns the value of the "created_at" field in the mutation. 2771 func (m *ItemMutation) CreatedAt() (r time.Time, exists bool) { 2772 v := m.created_at 2773 if v == nil { 2774 return 2775 } 2776 return *v, true 2777 } 2778 2779 // OldCreatedAt returns the old "created_at" field's value of the Item entity. 2780 // If the Item object wasn't provided to the builder, the object is fetched from the database. 2781 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2782 func (m *ItemMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { 2783 if !m.op.Is(OpUpdateOne) { 2784 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 2785 } 2786 if m.id == nil || m.oldValue == nil { 2787 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 2788 } 2789 oldValue, err := m.oldValue(ctx) 2790 if err != nil { 2791 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 2792 } 2793 return oldValue.CreatedAt, nil 2794 } 2795 2796 // ResetCreatedAt resets all changes to the "created_at" field. 2797 func (m *ItemMutation) ResetCreatedAt() { 2798 m.created_at = nil 2799 } 2800 2801 // SetUpdatedAt sets the "updated_at" field. 2802 func (m *ItemMutation) SetUpdatedAt(t time.Time) { 2803 m.updated_at = &t 2804 } 2805 2806 // UpdatedAt returns the value of the "updated_at" field in the mutation. 2807 func (m *ItemMutation) UpdatedAt() (r time.Time, exists bool) { 2808 v := m.updated_at 2809 if v == nil { 2810 return 2811 } 2812 return *v, true 2813 } 2814 2815 // OldUpdatedAt returns the old "updated_at" field's value of the Item entity. 2816 // If the Item object wasn't provided to the builder, the object is fetched from the database. 2817 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2818 func (m *ItemMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { 2819 if !m.op.Is(OpUpdateOne) { 2820 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 2821 } 2822 if m.id == nil || m.oldValue == nil { 2823 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 2824 } 2825 oldValue, err := m.oldValue(ctx) 2826 if err != nil { 2827 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 2828 } 2829 return oldValue.UpdatedAt, nil 2830 } 2831 2832 // ResetUpdatedAt resets all changes to the "updated_at" field. 2833 func (m *ItemMutation) ResetUpdatedAt() { 2834 m.updated_at = nil 2835 } 2836 2837 // SetFeedID sets the "feed" edge to the Feed entity by id. 2838 func (m *ItemMutation) SetFeedID(id uuid.UUID) { 2839 m.feed = &id 2840 } 2841 2842 // ClearFeed clears the "feed" edge to the Feed entity. 2843 func (m *ItemMutation) ClearFeed() { 2844 m.clearedfeed = true 2845 } 2846 2847 // FeedCleared reports if the "feed" edge to the Feed entity was cleared. 2848 func (m *ItemMutation) FeedCleared() bool { 2849 return m.clearedfeed 2850 } 2851 2852 // FeedID returns the "feed" edge ID in the mutation. 2853 func (m *ItemMutation) FeedID() (id uuid.UUID, exists bool) { 2854 if m.feed != nil { 2855 return *m.feed, true 2856 } 2857 return 2858 } 2859 2860 // FeedIDs returns the "feed" edge IDs in the mutation. 2861 // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use 2862 // FeedID instead. It exists only for internal usage by the builders. 2863 func (m *ItemMutation) FeedIDs() (ids []uuid.UUID) { 2864 if id := m.feed; id != nil { 2865 ids = append(ids, *id) 2866 } 2867 return 2868 } 2869 2870 // ResetFeed resets all changes to the "feed" edge. 2871 func (m *ItemMutation) ResetFeed() { 2872 m.feed = nil 2873 m.clearedfeed = false 2874 } 2875 2876 // AddReadByUserIDs adds the "read_by_users" edge to the User entity by ids. 2877 func (m *ItemMutation) AddReadByUserIDs(ids ...uuid.UUID) { 2878 if m.read_by_users == nil { 2879 m.read_by_users = make(map[uuid.UUID]struct{}) 2880 } 2881 for i := range ids { 2882 m.read_by_users[ids[i]] = struct{}{} 2883 } 2884 } 2885 2886 // ClearReadByUsers clears the "read_by_users" edge to the User entity. 2887 func (m *ItemMutation) ClearReadByUsers() { 2888 m.clearedread_by_users = true 2889 } 2890 2891 // ReadByUsersCleared reports if the "read_by_users" edge to the User entity was cleared. 2892 func (m *ItemMutation) ReadByUsersCleared() bool { 2893 return m.clearedread_by_users 2894 } 2895 2896 // RemoveReadByUserIDs removes the "read_by_users" edge to the User entity by IDs. 2897 func (m *ItemMutation) RemoveReadByUserIDs(ids ...uuid.UUID) { 2898 if m.removedread_by_users == nil { 2899 m.removedread_by_users = make(map[uuid.UUID]struct{}) 2900 } 2901 for i := range ids { 2902 delete(m.read_by_users, ids[i]) 2903 m.removedread_by_users[ids[i]] = struct{}{} 2904 } 2905 } 2906 2907 // RemovedReadByUsers returns the removed IDs of the "read_by_users" edge to the User entity. 2908 func (m *ItemMutation) RemovedReadByUsersIDs() (ids []uuid.UUID) { 2909 for id := range m.removedread_by_users { 2910 ids = append(ids, id) 2911 } 2912 return 2913 } 2914 2915 // ReadByUsersIDs returns the "read_by_users" edge IDs in the mutation. 2916 func (m *ItemMutation) ReadByUsersIDs() (ids []uuid.UUID) { 2917 for id := range m.read_by_users { 2918 ids = append(ids, id) 2919 } 2920 return 2921 } 2922 2923 // ResetReadByUsers resets all changes to the "read_by_users" edge. 2924 func (m *ItemMutation) ResetReadByUsers() { 2925 m.read_by_users = nil 2926 m.clearedread_by_users = false 2927 m.removedread_by_users = nil 2928 } 2929 2930 // AddReadIDs adds the "reads" edge to the Read entity by ids. 2931 func (m *ItemMutation) AddReadIDs(ids ...uuid.UUID) { 2932 if m.reads == nil { 2933 m.reads = make(map[uuid.UUID]struct{}) 2934 } 2935 for i := range ids { 2936 m.reads[ids[i]] = struct{}{} 2937 } 2938 } 2939 2940 // ClearReads clears the "reads" edge to the Read entity. 2941 func (m *ItemMutation) ClearReads() { 2942 m.clearedreads = true 2943 } 2944 2945 // ReadsCleared reports if the "reads" edge to the Read entity was cleared. 2946 func (m *ItemMutation) ReadsCleared() bool { 2947 return m.clearedreads 2948 } 2949 2950 // RemoveReadIDs removes the "reads" edge to the Read entity by IDs. 2951 func (m *ItemMutation) RemoveReadIDs(ids ...uuid.UUID) { 2952 if m.removedreads == nil { 2953 m.removedreads = make(map[uuid.UUID]struct{}) 2954 } 2955 for i := range ids { 2956 delete(m.reads, ids[i]) 2957 m.removedreads[ids[i]] = struct{}{} 2958 } 2959 } 2960 2961 // RemovedReads returns the removed IDs of the "reads" edge to the Read entity. 2962 func (m *ItemMutation) RemovedReadsIDs() (ids []uuid.UUID) { 2963 for id := range m.removedreads { 2964 ids = append(ids, id) 2965 } 2966 return 2967 } 2968 2969 // ReadsIDs returns the "reads" edge IDs in the mutation. 2970 func (m *ItemMutation) ReadsIDs() (ids []uuid.UUID) { 2971 for id := range m.reads { 2972 ids = append(ids, id) 2973 } 2974 return 2975 } 2976 2977 // ResetReads resets all changes to the "reads" edge. 2978 func (m *ItemMutation) ResetReads() { 2979 m.reads = nil 2980 m.clearedreads = false 2981 m.removedreads = nil 2982 } 2983 2984 // Where appends a list predicates to the ItemMutation builder. 2985 func (m *ItemMutation) Where(ps ...predicate.Item) { 2986 m.predicates = append(m.predicates, ps...) 2987 } 2988 2989 // WhereP appends storage-level predicates to the ItemMutation builder. Using this method, 2990 // users can use type-assertion to append predicates that do not depend on any generated package. 2991 func (m *ItemMutation) WhereP(ps ...func(*sql.Selector)) { 2992 p := make([]predicate.Item, len(ps)) 2993 for i := range ps { 2994 p[i] = ps[i] 2995 } 2996 m.Where(p...) 2997 } 2998 2999 // Op returns the operation name. 3000 func (m *ItemMutation) Op() Op { 3001 return m.op 3002 } 3003 3004 // SetOp allows setting the mutation operation. 3005 func (m *ItemMutation) SetOp(op Op) { 3006 m.op = op 3007 } 3008 3009 // Type returns the node type of this mutation (Item). 3010 func (m *ItemMutation) Type() string { 3011 return m.typ 3012 } 3013 3014 // Fields returns all fields that were changed during this mutation. Note that in 3015 // order to get all numeric fields that were incremented/decremented, call 3016 // AddedFields(). 3017 func (m *ItemMutation) Fields() []string { 3018 fields := make([]string, 0, 22) 3019 if m.item_guid != nil { 3020 fields = append(fields, item.FieldItemGUID) 3021 } 3022 if m.item_title != nil { 3023 fields = append(fields, item.FieldItemTitle) 3024 } 3025 if m.item_description != nil { 3026 fields = append(fields, item.FieldItemDescription) 3027 } 3028 if m.item_content != nil { 3029 fields = append(fields, item.FieldItemContent) 3030 } 3031 if m.item_link != nil { 3032 fields = append(fields, item.FieldItemLink) 3033 } 3034 if m.item_updated != nil { 3035 fields = append(fields, item.FieldItemUpdated) 3036 } 3037 if m.item_published != nil { 3038 fields = append(fields, item.FieldItemPublished) 3039 } 3040 if m.item_author_name != nil { 3041 fields = append(fields, item.FieldItemAuthorName) 3042 } 3043 if m.item_author_email != nil { 3044 fields = append(fields, item.FieldItemAuthorEmail) 3045 } 3046 if m.item_image_title != nil { 3047 fields = append(fields, item.FieldItemImageTitle) 3048 } 3049 if m.item_image_url != nil { 3050 fields = append(fields, item.FieldItemImageURL) 3051 } 3052 if m.item_categories != nil { 3053 fields = append(fields, item.FieldItemCategories) 3054 } 3055 if m.item_enclosures != nil { 3056 fields = append(fields, item.FieldItemEnclosures) 3057 } 3058 if m.crawler_title != nil { 3059 fields = append(fields, item.FieldCrawlerTitle) 3060 } 3061 if m.crawler_author != nil { 3062 fields = append(fields, item.FieldCrawlerAuthor) 3063 } 3064 if m.crawler_excerpt != nil { 3065 fields = append(fields, item.FieldCrawlerExcerpt) 3066 } 3067 if m.crawler_site_name != nil { 3068 fields = append(fields, item.FieldCrawlerSiteName) 3069 } 3070 if m.crawler_image != nil { 3071 fields = append(fields, item.FieldCrawlerImage) 3072 } 3073 if m.crawler_content_html != nil { 3074 fields = append(fields, item.FieldCrawlerContentHTML) 3075 } 3076 if m.crawler_content_text != nil { 3077 fields = append(fields, item.FieldCrawlerContentText) 3078 } 3079 if m.created_at != nil { 3080 fields = append(fields, item.FieldCreatedAt) 3081 } 3082 if m.updated_at != nil { 3083 fields = append(fields, item.FieldUpdatedAt) 3084 } 3085 return fields 3086 } 3087 3088 // Field returns the value of a field with the given name. The second boolean 3089 // return value indicates that this field was not set, or was not defined in the 3090 // schema. 3091 func (m *ItemMutation) Field(name string) (ent.Value, bool) { 3092 switch name { 3093 case item.FieldItemGUID: 3094 return m.ItemGUID() 3095 case item.FieldItemTitle: 3096 return m.ItemTitle() 3097 case item.FieldItemDescription: 3098 return m.ItemDescription() 3099 case item.FieldItemContent: 3100 return m.ItemContent() 3101 case item.FieldItemLink: 3102 return m.ItemLink() 3103 case item.FieldItemUpdated: 3104 return m.ItemUpdated() 3105 case item.FieldItemPublished: 3106 return m.ItemPublished() 3107 case item.FieldItemAuthorName: 3108 return m.ItemAuthorName() 3109 case item.FieldItemAuthorEmail: 3110 return m.ItemAuthorEmail() 3111 case item.FieldItemImageTitle: 3112 return m.ItemImageTitle() 3113 case item.FieldItemImageURL: 3114 return m.ItemImageURL() 3115 case item.FieldItemCategories: 3116 return m.ItemCategories() 3117 case item.FieldItemEnclosures: 3118 return m.ItemEnclosures() 3119 case item.FieldCrawlerTitle: 3120 return m.CrawlerTitle() 3121 case item.FieldCrawlerAuthor: 3122 return m.CrawlerAuthor() 3123 case item.FieldCrawlerExcerpt: 3124 return m.CrawlerExcerpt() 3125 case item.FieldCrawlerSiteName: 3126 return m.CrawlerSiteName() 3127 case item.FieldCrawlerImage: 3128 return m.CrawlerImage() 3129 case item.FieldCrawlerContentHTML: 3130 return m.CrawlerContentHTML() 3131 case item.FieldCrawlerContentText: 3132 return m.CrawlerContentText() 3133 case item.FieldCreatedAt: 3134 return m.CreatedAt() 3135 case item.FieldUpdatedAt: 3136 return m.UpdatedAt() 3137 } 3138 return nil, false 3139 } 3140 3141 // OldField returns the old value of the field from the database. An error is 3142 // returned if the mutation operation is not UpdateOne, or the query to the 3143 // database failed. 3144 func (m *ItemMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 3145 switch name { 3146 case item.FieldItemGUID: 3147 return m.OldItemGUID(ctx) 3148 case item.FieldItemTitle: 3149 return m.OldItemTitle(ctx) 3150 case item.FieldItemDescription: 3151 return m.OldItemDescription(ctx) 3152 case item.FieldItemContent: 3153 return m.OldItemContent(ctx) 3154 case item.FieldItemLink: 3155 return m.OldItemLink(ctx) 3156 case item.FieldItemUpdated: 3157 return m.OldItemUpdated(ctx) 3158 case item.FieldItemPublished: 3159 return m.OldItemPublished(ctx) 3160 case item.FieldItemAuthorName: 3161 return m.OldItemAuthorName(ctx) 3162 case item.FieldItemAuthorEmail: 3163 return m.OldItemAuthorEmail(ctx) 3164 case item.FieldItemImageTitle: 3165 return m.OldItemImageTitle(ctx) 3166 case item.FieldItemImageURL: 3167 return m.OldItemImageURL(ctx) 3168 case item.FieldItemCategories: 3169 return m.OldItemCategories(ctx) 3170 case item.FieldItemEnclosures: 3171 return m.OldItemEnclosures(ctx) 3172 case item.FieldCrawlerTitle: 3173 return m.OldCrawlerTitle(ctx) 3174 case item.FieldCrawlerAuthor: 3175 return m.OldCrawlerAuthor(ctx) 3176 case item.FieldCrawlerExcerpt: 3177 return m.OldCrawlerExcerpt(ctx) 3178 case item.FieldCrawlerSiteName: 3179 return m.OldCrawlerSiteName(ctx) 3180 case item.FieldCrawlerImage: 3181 return m.OldCrawlerImage(ctx) 3182 case item.FieldCrawlerContentHTML: 3183 return m.OldCrawlerContentHTML(ctx) 3184 case item.FieldCrawlerContentText: 3185 return m.OldCrawlerContentText(ctx) 3186 case item.FieldCreatedAt: 3187 return m.OldCreatedAt(ctx) 3188 case item.FieldUpdatedAt: 3189 return m.OldUpdatedAt(ctx) 3190 } 3191 return nil, fmt.Errorf("unknown Item field %s", name) 3192 } 3193 3194 // SetField sets the value of a field with the given name. It returns an error if 3195 // the field is not defined in the schema, or if the type mismatched the field 3196 // type. 3197 func (m *ItemMutation) SetField(name string, value ent.Value) error { 3198 switch name { 3199 case item.FieldItemGUID: 3200 v, ok := value.(string) 3201 if !ok { 3202 return fmt.Errorf("unexpected type %T for field %s", value, name) 3203 } 3204 m.SetItemGUID(v) 3205 return nil 3206 case item.FieldItemTitle: 3207 v, ok := value.(string) 3208 if !ok { 3209 return fmt.Errorf("unexpected type %T for field %s", value, name) 3210 } 3211 m.SetItemTitle(v) 3212 return nil 3213 case item.FieldItemDescription: 3214 v, ok := value.(string) 3215 if !ok { 3216 return fmt.Errorf("unexpected type %T for field %s", value, name) 3217 } 3218 m.SetItemDescription(v) 3219 return nil 3220 case item.FieldItemContent: 3221 v, ok := value.(string) 3222 if !ok { 3223 return fmt.Errorf("unexpected type %T for field %s", value, name) 3224 } 3225 m.SetItemContent(v) 3226 return nil 3227 case item.FieldItemLink: 3228 v, ok := value.(string) 3229 if !ok { 3230 return fmt.Errorf("unexpected type %T for field %s", value, name) 3231 } 3232 m.SetItemLink(v) 3233 return nil 3234 case item.FieldItemUpdated: 3235 v, ok := value.(time.Time) 3236 if !ok { 3237 return fmt.Errorf("unexpected type %T for field %s", value, name) 3238 } 3239 m.SetItemUpdated(v) 3240 return nil 3241 case item.FieldItemPublished: 3242 v, ok := value.(time.Time) 3243 if !ok { 3244 return fmt.Errorf("unexpected type %T for field %s", value, name) 3245 } 3246 m.SetItemPublished(v) 3247 return nil 3248 case item.FieldItemAuthorName: 3249 v, ok := value.(string) 3250 if !ok { 3251 return fmt.Errorf("unexpected type %T for field %s", value, name) 3252 } 3253 m.SetItemAuthorName(v) 3254 return nil 3255 case item.FieldItemAuthorEmail: 3256 v, ok := value.(string) 3257 if !ok { 3258 return fmt.Errorf("unexpected type %T for field %s", value, name) 3259 } 3260 m.SetItemAuthorEmail(v) 3261 return nil 3262 case item.FieldItemImageTitle: 3263 v, ok := value.(string) 3264 if !ok { 3265 return fmt.Errorf("unexpected type %T for field %s", value, name) 3266 } 3267 m.SetItemImageTitle(v) 3268 return nil 3269 case item.FieldItemImageURL: 3270 v, ok := value.(string) 3271 if !ok { 3272 return fmt.Errorf("unexpected type %T for field %s", value, name) 3273 } 3274 m.SetItemImageURL(v) 3275 return nil 3276 case item.FieldItemCategories: 3277 v, ok := value.(string) 3278 if !ok { 3279 return fmt.Errorf("unexpected type %T for field %s", value, name) 3280 } 3281 m.SetItemCategories(v) 3282 return nil 3283 case item.FieldItemEnclosures: 3284 v, ok := value.(string) 3285 if !ok { 3286 return fmt.Errorf("unexpected type %T for field %s", value, name) 3287 } 3288 m.SetItemEnclosures(v) 3289 return nil 3290 case item.FieldCrawlerTitle: 3291 v, ok := value.(string) 3292 if !ok { 3293 return fmt.Errorf("unexpected type %T for field %s", value, name) 3294 } 3295 m.SetCrawlerTitle(v) 3296 return nil 3297 case item.FieldCrawlerAuthor: 3298 v, ok := value.(string) 3299 if !ok { 3300 return fmt.Errorf("unexpected type %T for field %s", value, name) 3301 } 3302 m.SetCrawlerAuthor(v) 3303 return nil 3304 case item.FieldCrawlerExcerpt: 3305 v, ok := value.(string) 3306 if !ok { 3307 return fmt.Errorf("unexpected type %T for field %s", value, name) 3308 } 3309 m.SetCrawlerExcerpt(v) 3310 return nil 3311 case item.FieldCrawlerSiteName: 3312 v, ok := value.(string) 3313 if !ok { 3314 return fmt.Errorf("unexpected type %T for field %s", value, name) 3315 } 3316 m.SetCrawlerSiteName(v) 3317 return nil 3318 case item.FieldCrawlerImage: 3319 v, ok := value.(string) 3320 if !ok { 3321 return fmt.Errorf("unexpected type %T for field %s", value, name) 3322 } 3323 m.SetCrawlerImage(v) 3324 return nil 3325 case item.FieldCrawlerContentHTML: 3326 v, ok := value.(string) 3327 if !ok { 3328 return fmt.Errorf("unexpected type %T for field %s", value, name) 3329 } 3330 m.SetCrawlerContentHTML(v) 3331 return nil 3332 case item.FieldCrawlerContentText: 3333 v, ok := value.(string) 3334 if !ok { 3335 return fmt.Errorf("unexpected type %T for field %s", value, name) 3336 } 3337 m.SetCrawlerContentText(v) 3338 return nil 3339 case item.FieldCreatedAt: 3340 v, ok := value.(time.Time) 3341 if !ok { 3342 return fmt.Errorf("unexpected type %T for field %s", value, name) 3343 } 3344 m.SetCreatedAt(v) 3345 return nil 3346 case item.FieldUpdatedAt: 3347 v, ok := value.(time.Time) 3348 if !ok { 3349 return fmt.Errorf("unexpected type %T for field %s", value, name) 3350 } 3351 m.SetUpdatedAt(v) 3352 return nil 3353 } 3354 return fmt.Errorf("unknown Item field %s", name) 3355 } 3356 3357 // AddedFields returns all numeric fields that were incremented/decremented during 3358 // this mutation. 3359 func (m *ItemMutation) AddedFields() []string { 3360 return nil 3361 } 3362 3363 // AddedField returns the numeric value that was incremented/decremented on a field 3364 // with the given name. The second boolean return value indicates that this field 3365 // was not set, or was not defined in the schema. 3366 func (m *ItemMutation) AddedField(name string) (ent.Value, bool) { 3367 return nil, false 3368 } 3369 3370 // AddField adds the value to the field with the given name. It returns an error if 3371 // the field is not defined in the schema, or if the type mismatched the field 3372 // type. 3373 func (m *ItemMutation) AddField(name string, value ent.Value) error { 3374 switch name { 3375 } 3376 return fmt.Errorf("unknown Item numeric field %s", name) 3377 } 3378 3379 // ClearedFields returns all nullable fields that were cleared during this 3380 // mutation. 3381 func (m *ItemMutation) ClearedFields() []string { 3382 var fields []string 3383 if m.FieldCleared(item.FieldItemAuthorName) { 3384 fields = append(fields, item.FieldItemAuthorName) 3385 } 3386 if m.FieldCleared(item.FieldItemAuthorEmail) { 3387 fields = append(fields, item.FieldItemAuthorEmail) 3388 } 3389 if m.FieldCleared(item.FieldItemImageTitle) { 3390 fields = append(fields, item.FieldItemImageTitle) 3391 } 3392 if m.FieldCleared(item.FieldItemImageURL) { 3393 fields = append(fields, item.FieldItemImageURL) 3394 } 3395 if m.FieldCleared(item.FieldCrawlerTitle) { 3396 fields = append(fields, item.FieldCrawlerTitle) 3397 } 3398 if m.FieldCleared(item.FieldCrawlerAuthor) { 3399 fields = append(fields, item.FieldCrawlerAuthor) 3400 } 3401 if m.FieldCleared(item.FieldCrawlerExcerpt) { 3402 fields = append(fields, item.FieldCrawlerExcerpt) 3403 } 3404 if m.FieldCleared(item.FieldCrawlerSiteName) { 3405 fields = append(fields, item.FieldCrawlerSiteName) 3406 } 3407 if m.FieldCleared(item.FieldCrawlerImage) { 3408 fields = append(fields, item.FieldCrawlerImage) 3409 } 3410 if m.FieldCleared(item.FieldCrawlerContentHTML) { 3411 fields = append(fields, item.FieldCrawlerContentHTML) 3412 } 3413 if m.FieldCleared(item.FieldCrawlerContentText) { 3414 fields = append(fields, item.FieldCrawlerContentText) 3415 } 3416 return fields 3417 } 3418 3419 // FieldCleared returns a boolean indicating if a field with the given name was 3420 // cleared in this mutation. 3421 func (m *ItemMutation) FieldCleared(name string) bool { 3422 _, ok := m.clearedFields[name] 3423 return ok 3424 } 3425 3426 // ClearField clears the value of the field with the given name. It returns an 3427 // error if the field is not defined in the schema. 3428 func (m *ItemMutation) ClearField(name string) error { 3429 switch name { 3430 case item.FieldItemAuthorName: 3431 m.ClearItemAuthorName() 3432 return nil 3433 case item.FieldItemAuthorEmail: 3434 m.ClearItemAuthorEmail() 3435 return nil 3436 case item.FieldItemImageTitle: 3437 m.ClearItemImageTitle() 3438 return nil 3439 case item.FieldItemImageURL: 3440 m.ClearItemImageURL() 3441 return nil 3442 case item.FieldCrawlerTitle: 3443 m.ClearCrawlerTitle() 3444 return nil 3445 case item.FieldCrawlerAuthor: 3446 m.ClearCrawlerAuthor() 3447 return nil 3448 case item.FieldCrawlerExcerpt: 3449 m.ClearCrawlerExcerpt() 3450 return nil 3451 case item.FieldCrawlerSiteName: 3452 m.ClearCrawlerSiteName() 3453 return nil 3454 case item.FieldCrawlerImage: 3455 m.ClearCrawlerImage() 3456 return nil 3457 case item.FieldCrawlerContentHTML: 3458 m.ClearCrawlerContentHTML() 3459 return nil 3460 case item.FieldCrawlerContentText: 3461 m.ClearCrawlerContentText() 3462 return nil 3463 } 3464 return fmt.Errorf("unknown Item nullable field %s", name) 3465 } 3466 3467 // ResetField resets all changes in the mutation for the field with the given name. 3468 // It returns an error if the field is not defined in the schema. 3469 func (m *ItemMutation) ResetField(name string) error { 3470 switch name { 3471 case item.FieldItemGUID: 3472 m.ResetItemGUID() 3473 return nil 3474 case item.FieldItemTitle: 3475 m.ResetItemTitle() 3476 return nil 3477 case item.FieldItemDescription: 3478 m.ResetItemDescription() 3479 return nil 3480 case item.FieldItemContent: 3481 m.ResetItemContent() 3482 return nil 3483 case item.FieldItemLink: 3484 m.ResetItemLink() 3485 return nil 3486 case item.FieldItemUpdated: 3487 m.ResetItemUpdated() 3488 return nil 3489 case item.FieldItemPublished: 3490 m.ResetItemPublished() 3491 return nil 3492 case item.FieldItemAuthorName: 3493 m.ResetItemAuthorName() 3494 return nil 3495 case item.FieldItemAuthorEmail: 3496 m.ResetItemAuthorEmail() 3497 return nil 3498 case item.FieldItemImageTitle: 3499 m.ResetItemImageTitle() 3500 return nil 3501 case item.FieldItemImageURL: 3502 m.ResetItemImageURL() 3503 return nil 3504 case item.FieldItemCategories: 3505 m.ResetItemCategories() 3506 return nil 3507 case item.FieldItemEnclosures: 3508 m.ResetItemEnclosures() 3509 return nil 3510 case item.FieldCrawlerTitle: 3511 m.ResetCrawlerTitle() 3512 return nil 3513 case item.FieldCrawlerAuthor: 3514 m.ResetCrawlerAuthor() 3515 return nil 3516 case item.FieldCrawlerExcerpt: 3517 m.ResetCrawlerExcerpt() 3518 return nil 3519 case item.FieldCrawlerSiteName: 3520 m.ResetCrawlerSiteName() 3521 return nil 3522 case item.FieldCrawlerImage: 3523 m.ResetCrawlerImage() 3524 return nil 3525 case item.FieldCrawlerContentHTML: 3526 m.ResetCrawlerContentHTML() 3527 return nil 3528 case item.FieldCrawlerContentText: 3529 m.ResetCrawlerContentText() 3530 return nil 3531 case item.FieldCreatedAt: 3532 m.ResetCreatedAt() 3533 return nil 3534 case item.FieldUpdatedAt: 3535 m.ResetUpdatedAt() 3536 return nil 3537 } 3538 return fmt.Errorf("unknown Item field %s", name) 3539 } 3540 3541 // AddedEdges returns all edge names that were set/added in this mutation. 3542 func (m *ItemMutation) AddedEdges() []string { 3543 edges := make([]string, 0, 3) 3544 if m.feed != nil { 3545 edges = append(edges, item.EdgeFeed) 3546 } 3547 if m.read_by_users != nil { 3548 edges = append(edges, item.EdgeReadByUsers) 3549 } 3550 if m.reads != nil { 3551 edges = append(edges, item.EdgeReads) 3552 } 3553 return edges 3554 } 3555 3556 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 3557 // name in this mutation. 3558 func (m *ItemMutation) AddedIDs(name string) []ent.Value { 3559 switch name { 3560 case item.EdgeFeed: 3561 if id := m.feed; id != nil { 3562 return []ent.Value{*id} 3563 } 3564 case item.EdgeReadByUsers: 3565 ids := make([]ent.Value, 0, len(m.read_by_users)) 3566 for id := range m.read_by_users { 3567 ids = append(ids, id) 3568 } 3569 return ids 3570 case item.EdgeReads: 3571 ids := make([]ent.Value, 0, len(m.reads)) 3572 for id := range m.reads { 3573 ids = append(ids, id) 3574 } 3575 return ids 3576 } 3577 return nil 3578 } 3579 3580 // RemovedEdges returns all edge names that were removed in this mutation. 3581 func (m *ItemMutation) RemovedEdges() []string { 3582 edges := make([]string, 0, 3) 3583 if m.removedread_by_users != nil { 3584 edges = append(edges, item.EdgeReadByUsers) 3585 } 3586 if m.removedreads != nil { 3587 edges = append(edges, item.EdgeReads) 3588 } 3589 return edges 3590 } 3591 3592 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 3593 // the given name in this mutation. 3594 func (m *ItemMutation) RemovedIDs(name string) []ent.Value { 3595 switch name { 3596 case item.EdgeReadByUsers: 3597 ids := make([]ent.Value, 0, len(m.removedread_by_users)) 3598 for id := range m.removedread_by_users { 3599 ids = append(ids, id) 3600 } 3601 return ids 3602 case item.EdgeReads: 3603 ids := make([]ent.Value, 0, len(m.removedreads)) 3604 for id := range m.removedreads { 3605 ids = append(ids, id) 3606 } 3607 return ids 3608 } 3609 return nil 3610 } 3611 3612 // ClearedEdges returns all edge names that were cleared in this mutation. 3613 func (m *ItemMutation) ClearedEdges() []string { 3614 edges := make([]string, 0, 3) 3615 if m.clearedfeed { 3616 edges = append(edges, item.EdgeFeed) 3617 } 3618 if m.clearedread_by_users { 3619 edges = append(edges, item.EdgeReadByUsers) 3620 } 3621 if m.clearedreads { 3622 edges = append(edges, item.EdgeReads) 3623 } 3624 return edges 3625 } 3626 3627 // EdgeCleared returns a boolean which indicates if the edge with the given name 3628 // was cleared in this mutation. 3629 func (m *ItemMutation) EdgeCleared(name string) bool { 3630 switch name { 3631 case item.EdgeFeed: 3632 return m.clearedfeed 3633 case item.EdgeReadByUsers: 3634 return m.clearedread_by_users 3635 case item.EdgeReads: 3636 return m.clearedreads 3637 } 3638 return false 3639 } 3640 3641 // ClearEdge clears the value of the edge with the given name. It returns an error 3642 // if that edge is not defined in the schema. 3643 func (m *ItemMutation) ClearEdge(name string) error { 3644 switch name { 3645 case item.EdgeFeed: 3646 m.ClearFeed() 3647 return nil 3648 } 3649 return fmt.Errorf("unknown Item unique edge %s", name) 3650 } 3651 3652 // ResetEdge resets all changes to the edge with the given name in this mutation. 3653 // It returns an error if the edge is not defined in the schema. 3654 func (m *ItemMutation) ResetEdge(name string) error { 3655 switch name { 3656 case item.EdgeFeed: 3657 m.ResetFeed() 3658 return nil 3659 case item.EdgeReadByUsers: 3660 m.ResetReadByUsers() 3661 return nil 3662 case item.EdgeReads: 3663 m.ResetReads() 3664 return nil 3665 } 3666 return fmt.Errorf("unknown Item edge %s", name) 3667 } 3668 3669 // ReadMutation represents an operation that mutates the Read nodes in the graph. 3670 type ReadMutation struct { 3671 config 3672 op Op 3673 typ string 3674 id *uuid.UUID 3675 created_at *time.Time 3676 clearedFields map[string]struct{} 3677 user *uuid.UUID 3678 cleareduser bool 3679 item *uuid.UUID 3680 cleareditem bool 3681 done bool 3682 oldValue func(context.Context) (*Read, error) 3683 predicates []predicate.Read 3684 } 3685 3686 var _ ent.Mutation = (*ReadMutation)(nil) 3687 3688 // readOption allows management of the mutation configuration using functional options. 3689 type readOption func(*ReadMutation) 3690 3691 // newReadMutation creates new mutation for the Read entity. 3692 func newReadMutation(c config, op Op, opts ...readOption) *ReadMutation { 3693 m := &ReadMutation{ 3694 config: c, 3695 op: op, 3696 typ: TypeRead, 3697 clearedFields: make(map[string]struct{}), 3698 } 3699 for _, opt := range opts { 3700 opt(m) 3701 } 3702 return m 3703 } 3704 3705 // withReadID sets the ID field of the mutation. 3706 func withReadID(id uuid.UUID) readOption { 3707 return func(m *ReadMutation) { 3708 var ( 3709 err error 3710 once sync.Once 3711 value *Read 3712 ) 3713 m.oldValue = func(ctx context.Context) (*Read, error) { 3714 once.Do(func() { 3715 if m.done { 3716 err = errors.New("querying old values post mutation is not allowed") 3717 } else { 3718 value, err = m.Client().Read.Get(ctx, id) 3719 } 3720 }) 3721 return value, err 3722 } 3723 m.id = &id 3724 } 3725 } 3726 3727 // withRead sets the old Read of the mutation. 3728 func withRead(node *Read) readOption { 3729 return func(m *ReadMutation) { 3730 m.oldValue = func(context.Context) (*Read, error) { 3731 return node, nil 3732 } 3733 m.id = &node.ID 3734 } 3735 } 3736 3737 // Client returns a new `ent.Client` from the mutation. If the mutation was 3738 // executed in a transaction (ent.Tx), a transactional client is returned. 3739 func (m ReadMutation) Client() *Client { 3740 client := &Client{config: m.config} 3741 client.init() 3742 return client 3743 } 3744 3745 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 3746 // it returns an error otherwise. 3747 func (m ReadMutation) Tx() (*Tx, error) { 3748 if _, ok := m.driver.(*txDriver); !ok { 3749 return nil, errors.New("ent: mutation is not running in a transaction") 3750 } 3751 tx := &Tx{config: m.config} 3752 tx.init() 3753 return tx, nil 3754 } 3755 3756 // SetID sets the value of the id field. Note that this 3757 // operation is only accepted on creation of Read entities. 3758 func (m *ReadMutation) SetID(id uuid.UUID) { 3759 m.id = &id 3760 } 3761 3762 // ID returns the ID value in the mutation. Note that the ID is only available 3763 // if it was provided to the builder or after it was returned from the database. 3764 func (m *ReadMutation) ID() (id uuid.UUID, exists bool) { 3765 if m.id == nil { 3766 return 3767 } 3768 return *m.id, true 3769 } 3770 3771 // IDs queries the database and returns the entity ids that match the mutation's predicate. 3772 // That means, if the mutation is applied within a transaction with an isolation level such 3773 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 3774 // or updated by the mutation. 3775 func (m *ReadMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { 3776 switch { 3777 case m.op.Is(OpUpdateOne | OpDeleteOne): 3778 id, exists := m.ID() 3779 if exists { 3780 return []uuid.UUID{id}, nil 3781 } 3782 fallthrough 3783 case m.op.Is(OpUpdate | OpDelete): 3784 return m.Client().Read.Query().Where(m.predicates...).IDs(ctx) 3785 default: 3786 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 3787 } 3788 } 3789 3790 // SetUserID sets the "user_id" field. 3791 func (m *ReadMutation) SetUserID(u uuid.UUID) { 3792 m.user = &u 3793 } 3794 3795 // UserID returns the value of the "user_id" field in the mutation. 3796 func (m *ReadMutation) UserID() (r uuid.UUID, exists bool) { 3797 v := m.user 3798 if v == nil { 3799 return 3800 } 3801 return *v, true 3802 } 3803 3804 // OldUserID returns the old "user_id" field's value of the Read entity. 3805 // If the Read object wasn't provided to the builder, the object is fetched from the database. 3806 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 3807 func (m *ReadMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { 3808 if !m.op.Is(OpUpdateOne) { 3809 return v, errors.New("OldUserID is only allowed on UpdateOne operations") 3810 } 3811 if m.id == nil || m.oldValue == nil { 3812 return v, errors.New("OldUserID requires an ID field in the mutation") 3813 } 3814 oldValue, err := m.oldValue(ctx) 3815 if err != nil { 3816 return v, fmt.Errorf("querying old value for OldUserID: %w", err) 3817 } 3818 return oldValue.UserID, nil 3819 } 3820 3821 // ResetUserID resets all changes to the "user_id" field. 3822 func (m *ReadMutation) ResetUserID() { 3823 m.user = nil 3824 } 3825 3826 // SetItemID sets the "item_id" field. 3827 func (m *ReadMutation) SetItemID(u uuid.UUID) { 3828 m.item = &u 3829 } 3830 3831 // ItemID returns the value of the "item_id" field in the mutation. 3832 func (m *ReadMutation) ItemID() (r uuid.UUID, exists bool) { 3833 v := m.item 3834 if v == nil { 3835 return 3836 } 3837 return *v, true 3838 } 3839 3840 // OldItemID returns the old "item_id" field's value of the Read entity. 3841 // If the Read object wasn't provided to the builder, the object is fetched from the database. 3842 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 3843 func (m *ReadMutation) OldItemID(ctx context.Context) (v uuid.UUID, err error) { 3844 if !m.op.Is(OpUpdateOne) { 3845 return v, errors.New("OldItemID is only allowed on UpdateOne operations") 3846 } 3847 if m.id == nil || m.oldValue == nil { 3848 return v, errors.New("OldItemID requires an ID field in the mutation") 3849 } 3850 oldValue, err := m.oldValue(ctx) 3851 if err != nil { 3852 return v, fmt.Errorf("querying old value for OldItemID: %w", err) 3853 } 3854 return oldValue.ItemID, nil 3855 } 3856 3857 // ResetItemID resets all changes to the "item_id" field. 3858 func (m *ReadMutation) ResetItemID() { 3859 m.item = nil 3860 } 3861 3862 // SetCreatedAt sets the "created_at" field. 3863 func (m *ReadMutation) SetCreatedAt(t time.Time) { 3864 m.created_at = &t 3865 } 3866 3867 // CreatedAt returns the value of the "created_at" field in the mutation. 3868 func (m *ReadMutation) CreatedAt() (r time.Time, exists bool) { 3869 v := m.created_at 3870 if v == nil { 3871 return 3872 } 3873 return *v, true 3874 } 3875 3876 // OldCreatedAt returns the old "created_at" field's value of the Read entity. 3877 // If the Read object wasn't provided to the builder, the object is fetched from the database. 3878 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 3879 func (m *ReadMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { 3880 if !m.op.Is(OpUpdateOne) { 3881 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 3882 } 3883 if m.id == nil || m.oldValue == nil { 3884 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 3885 } 3886 oldValue, err := m.oldValue(ctx) 3887 if err != nil { 3888 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 3889 } 3890 return oldValue.CreatedAt, nil 3891 } 3892 3893 // ResetCreatedAt resets all changes to the "created_at" field. 3894 func (m *ReadMutation) ResetCreatedAt() { 3895 m.created_at = nil 3896 } 3897 3898 // ClearUser clears the "user" edge to the User entity. 3899 func (m *ReadMutation) ClearUser() { 3900 m.cleareduser = true 3901 m.clearedFields[read.FieldUserID] = struct{}{} 3902 } 3903 3904 // UserCleared reports if the "user" edge to the User entity was cleared. 3905 func (m *ReadMutation) UserCleared() bool { 3906 return m.cleareduser 3907 } 3908 3909 // UserIDs returns the "user" edge IDs in the mutation. 3910 // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use 3911 // UserID instead. It exists only for internal usage by the builders. 3912 func (m *ReadMutation) UserIDs() (ids []uuid.UUID) { 3913 if id := m.user; id != nil { 3914 ids = append(ids, *id) 3915 } 3916 return 3917 } 3918 3919 // ResetUser resets all changes to the "user" edge. 3920 func (m *ReadMutation) ResetUser() { 3921 m.user = nil 3922 m.cleareduser = false 3923 } 3924 3925 // ClearItem clears the "item" edge to the Item entity. 3926 func (m *ReadMutation) ClearItem() { 3927 m.cleareditem = true 3928 m.clearedFields[read.FieldItemID] = struct{}{} 3929 } 3930 3931 // ItemCleared reports if the "item" edge to the Item entity was cleared. 3932 func (m *ReadMutation) ItemCleared() bool { 3933 return m.cleareditem 3934 } 3935 3936 // ItemIDs returns the "item" edge IDs in the mutation. 3937 // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use 3938 // ItemID instead. It exists only for internal usage by the builders. 3939 func (m *ReadMutation) ItemIDs() (ids []uuid.UUID) { 3940 if id := m.item; id != nil { 3941 ids = append(ids, *id) 3942 } 3943 return 3944 } 3945 3946 // ResetItem resets all changes to the "item" edge. 3947 func (m *ReadMutation) ResetItem() { 3948 m.item = nil 3949 m.cleareditem = false 3950 } 3951 3952 // Where appends a list predicates to the ReadMutation builder. 3953 func (m *ReadMutation) Where(ps ...predicate.Read) { 3954 m.predicates = append(m.predicates, ps...) 3955 } 3956 3957 // WhereP appends storage-level predicates to the ReadMutation builder. Using this method, 3958 // users can use type-assertion to append predicates that do not depend on any generated package. 3959 func (m *ReadMutation) WhereP(ps ...func(*sql.Selector)) { 3960 p := make([]predicate.Read, len(ps)) 3961 for i := range ps { 3962 p[i] = ps[i] 3963 } 3964 m.Where(p...) 3965 } 3966 3967 // Op returns the operation name. 3968 func (m *ReadMutation) Op() Op { 3969 return m.op 3970 } 3971 3972 // SetOp allows setting the mutation operation. 3973 func (m *ReadMutation) SetOp(op Op) { 3974 m.op = op 3975 } 3976 3977 // Type returns the node type of this mutation (Read). 3978 func (m *ReadMutation) Type() string { 3979 return m.typ 3980 } 3981 3982 // Fields returns all fields that were changed during this mutation. Note that in 3983 // order to get all numeric fields that were incremented/decremented, call 3984 // AddedFields(). 3985 func (m *ReadMutation) Fields() []string { 3986 fields := make([]string, 0, 3) 3987 if m.user != nil { 3988 fields = append(fields, read.FieldUserID) 3989 } 3990 if m.item != nil { 3991 fields = append(fields, read.FieldItemID) 3992 } 3993 if m.created_at != nil { 3994 fields = append(fields, read.FieldCreatedAt) 3995 } 3996 return fields 3997 } 3998 3999 // Field returns the value of a field with the given name. The second boolean 4000 // return value indicates that this field was not set, or was not defined in the 4001 // schema. 4002 func (m *ReadMutation) Field(name string) (ent.Value, bool) { 4003 switch name { 4004 case read.FieldUserID: 4005 return m.UserID() 4006 case read.FieldItemID: 4007 return m.ItemID() 4008 case read.FieldCreatedAt: 4009 return m.CreatedAt() 4010 } 4011 return nil, false 4012 } 4013 4014 // OldField returns the old value of the field from the database. An error is 4015 // returned if the mutation operation is not UpdateOne, or the query to the 4016 // database failed. 4017 func (m *ReadMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 4018 switch name { 4019 case read.FieldUserID: 4020 return m.OldUserID(ctx) 4021 case read.FieldItemID: 4022 return m.OldItemID(ctx) 4023 case read.FieldCreatedAt: 4024 return m.OldCreatedAt(ctx) 4025 } 4026 return nil, fmt.Errorf("unknown Read field %s", name) 4027 } 4028 4029 // SetField sets the value of a field with the given name. It returns an error if 4030 // the field is not defined in the schema, or if the type mismatched the field 4031 // type. 4032 func (m *ReadMutation) SetField(name string, value ent.Value) error { 4033 switch name { 4034 case read.FieldUserID: 4035 v, ok := value.(uuid.UUID) 4036 if !ok { 4037 return fmt.Errorf("unexpected type %T for field %s", value, name) 4038 } 4039 m.SetUserID(v) 4040 return nil 4041 case read.FieldItemID: 4042 v, ok := value.(uuid.UUID) 4043 if !ok { 4044 return fmt.Errorf("unexpected type %T for field %s", value, name) 4045 } 4046 m.SetItemID(v) 4047 return nil 4048 case read.FieldCreatedAt: 4049 v, ok := value.(time.Time) 4050 if !ok { 4051 return fmt.Errorf("unexpected type %T for field %s", value, name) 4052 } 4053 m.SetCreatedAt(v) 4054 return nil 4055 } 4056 return fmt.Errorf("unknown Read field %s", name) 4057 } 4058 4059 // AddedFields returns all numeric fields that were incremented/decremented during 4060 // this mutation. 4061 func (m *ReadMutation) AddedFields() []string { 4062 return nil 4063 } 4064 4065 // AddedField returns the numeric value that was incremented/decremented on a field 4066 // with the given name. The second boolean return value indicates that this field 4067 // was not set, or was not defined in the schema. 4068 func (m *ReadMutation) AddedField(name string) (ent.Value, bool) { 4069 return nil, false 4070 } 4071 4072 // AddField adds the value to the field with the given name. It returns an error if 4073 // the field is not defined in the schema, or if the type mismatched the field 4074 // type. 4075 func (m *ReadMutation) AddField(name string, value ent.Value) error { 4076 switch name { 4077 } 4078 return fmt.Errorf("unknown Read numeric field %s", name) 4079 } 4080 4081 // ClearedFields returns all nullable fields that were cleared during this 4082 // mutation. 4083 func (m *ReadMutation) ClearedFields() []string { 4084 return nil 4085 } 4086 4087 // FieldCleared returns a boolean indicating if a field with the given name was 4088 // cleared in this mutation. 4089 func (m *ReadMutation) FieldCleared(name string) bool { 4090 _, ok := m.clearedFields[name] 4091 return ok 4092 } 4093 4094 // ClearField clears the value of the field with the given name. It returns an 4095 // error if the field is not defined in the schema. 4096 func (m *ReadMutation) ClearField(name string) error { 4097 return fmt.Errorf("unknown Read nullable field %s", name) 4098 } 4099 4100 // ResetField resets all changes in the mutation for the field with the given name. 4101 // It returns an error if the field is not defined in the schema. 4102 func (m *ReadMutation) ResetField(name string) error { 4103 switch name { 4104 case read.FieldUserID: 4105 m.ResetUserID() 4106 return nil 4107 case read.FieldItemID: 4108 m.ResetItemID() 4109 return nil 4110 case read.FieldCreatedAt: 4111 m.ResetCreatedAt() 4112 return nil 4113 } 4114 return fmt.Errorf("unknown Read field %s", name) 4115 } 4116 4117 // AddedEdges returns all edge names that were set/added in this mutation. 4118 func (m *ReadMutation) AddedEdges() []string { 4119 edges := make([]string, 0, 2) 4120 if m.user != nil { 4121 edges = append(edges, read.EdgeUser) 4122 } 4123 if m.item != nil { 4124 edges = append(edges, read.EdgeItem) 4125 } 4126 return edges 4127 } 4128 4129 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 4130 // name in this mutation. 4131 func (m *ReadMutation) AddedIDs(name string) []ent.Value { 4132 switch name { 4133 case read.EdgeUser: 4134 if id := m.user; id != nil { 4135 return []ent.Value{*id} 4136 } 4137 case read.EdgeItem: 4138 if id := m.item; id != nil { 4139 return []ent.Value{*id} 4140 } 4141 } 4142 return nil 4143 } 4144 4145 // RemovedEdges returns all edge names that were removed in this mutation. 4146 func (m *ReadMutation) RemovedEdges() []string { 4147 edges := make([]string, 0, 2) 4148 return edges 4149 } 4150 4151 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 4152 // the given name in this mutation. 4153 func (m *ReadMutation) RemovedIDs(name string) []ent.Value { 4154 return nil 4155 } 4156 4157 // ClearedEdges returns all edge names that were cleared in this mutation. 4158 func (m *ReadMutation) ClearedEdges() []string { 4159 edges := make([]string, 0, 2) 4160 if m.cleareduser { 4161 edges = append(edges, read.EdgeUser) 4162 } 4163 if m.cleareditem { 4164 edges = append(edges, read.EdgeItem) 4165 } 4166 return edges 4167 } 4168 4169 // EdgeCleared returns a boolean which indicates if the edge with the given name 4170 // was cleared in this mutation. 4171 func (m *ReadMutation) EdgeCleared(name string) bool { 4172 switch name { 4173 case read.EdgeUser: 4174 return m.cleareduser 4175 case read.EdgeItem: 4176 return m.cleareditem 4177 } 4178 return false 4179 } 4180 4181 // ClearEdge clears the value of the edge with the given name. It returns an error 4182 // if that edge is not defined in the schema. 4183 func (m *ReadMutation) ClearEdge(name string) error { 4184 switch name { 4185 case read.EdgeUser: 4186 m.ClearUser() 4187 return nil 4188 case read.EdgeItem: 4189 m.ClearItem() 4190 return nil 4191 } 4192 return fmt.Errorf("unknown Read unique edge %s", name) 4193 } 4194 4195 // ResetEdge resets all changes to the edge with the given name in this mutation. 4196 // It returns an error if the edge is not defined in the schema. 4197 func (m *ReadMutation) ResetEdge(name string) error { 4198 switch name { 4199 case read.EdgeUser: 4200 m.ResetUser() 4201 return nil 4202 case read.EdgeItem: 4203 m.ResetItem() 4204 return nil 4205 } 4206 return fmt.Errorf("unknown Read edge %s", name) 4207 } 4208 4209 // SubscriptionMutation represents an operation that mutates the Subscription nodes in the graph. 4210 type SubscriptionMutation struct { 4211 config 4212 op Op 4213 typ string 4214 id *uuid.UUID 4215 name *string 4216 group *string 4217 created_at *time.Time 4218 clearedFields map[string]struct{} 4219 user *uuid.UUID 4220 cleareduser bool 4221 feed *uuid.UUID 4222 clearedfeed bool 4223 done bool 4224 oldValue func(context.Context) (*Subscription, error) 4225 predicates []predicate.Subscription 4226 } 4227 4228 var _ ent.Mutation = (*SubscriptionMutation)(nil) 4229 4230 // subscriptionOption allows management of the mutation configuration using functional options. 4231 type subscriptionOption func(*SubscriptionMutation) 4232 4233 // newSubscriptionMutation creates new mutation for the Subscription entity. 4234 func newSubscriptionMutation(c config, op Op, opts ...subscriptionOption) *SubscriptionMutation { 4235 m := &SubscriptionMutation{ 4236 config: c, 4237 op: op, 4238 typ: TypeSubscription, 4239 clearedFields: make(map[string]struct{}), 4240 } 4241 for _, opt := range opts { 4242 opt(m) 4243 } 4244 return m 4245 } 4246 4247 // withSubscriptionID sets the ID field of the mutation. 4248 func withSubscriptionID(id uuid.UUID) subscriptionOption { 4249 return func(m *SubscriptionMutation) { 4250 var ( 4251 err error 4252 once sync.Once 4253 value *Subscription 4254 ) 4255 m.oldValue = func(ctx context.Context) (*Subscription, error) { 4256 once.Do(func() { 4257 if m.done { 4258 err = errors.New("querying old values post mutation is not allowed") 4259 } else { 4260 value, err = m.Client().Subscription.Get(ctx, id) 4261 } 4262 }) 4263 return value, err 4264 } 4265 m.id = &id 4266 } 4267 } 4268 4269 // withSubscription sets the old Subscription of the mutation. 4270 func withSubscription(node *Subscription) subscriptionOption { 4271 return func(m *SubscriptionMutation) { 4272 m.oldValue = func(context.Context) (*Subscription, error) { 4273 return node, nil 4274 } 4275 m.id = &node.ID 4276 } 4277 } 4278 4279 // Client returns a new `ent.Client` from the mutation. If the mutation was 4280 // executed in a transaction (ent.Tx), a transactional client is returned. 4281 func (m SubscriptionMutation) Client() *Client { 4282 client := &Client{config: m.config} 4283 client.init() 4284 return client 4285 } 4286 4287 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 4288 // it returns an error otherwise. 4289 func (m SubscriptionMutation) Tx() (*Tx, error) { 4290 if _, ok := m.driver.(*txDriver); !ok { 4291 return nil, errors.New("ent: mutation is not running in a transaction") 4292 } 4293 tx := &Tx{config: m.config} 4294 tx.init() 4295 return tx, nil 4296 } 4297 4298 // SetID sets the value of the id field. Note that this 4299 // operation is only accepted on creation of Subscription entities. 4300 func (m *SubscriptionMutation) SetID(id uuid.UUID) { 4301 m.id = &id 4302 } 4303 4304 // ID returns the ID value in the mutation. Note that the ID is only available 4305 // if it was provided to the builder or after it was returned from the database. 4306 func (m *SubscriptionMutation) ID() (id uuid.UUID, exists bool) { 4307 if m.id == nil { 4308 return 4309 } 4310 return *m.id, true 4311 } 4312 4313 // IDs queries the database and returns the entity ids that match the mutation's predicate. 4314 // That means, if the mutation is applied within a transaction with an isolation level such 4315 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 4316 // or updated by the mutation. 4317 func (m *SubscriptionMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { 4318 switch { 4319 case m.op.Is(OpUpdateOne | OpDeleteOne): 4320 id, exists := m.ID() 4321 if exists { 4322 return []uuid.UUID{id}, nil 4323 } 4324 fallthrough 4325 case m.op.Is(OpUpdate | OpDelete): 4326 return m.Client().Subscription.Query().Where(m.predicates...).IDs(ctx) 4327 default: 4328 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 4329 } 4330 } 4331 4332 // SetUserID sets the "user_id" field. 4333 func (m *SubscriptionMutation) SetUserID(u uuid.UUID) { 4334 m.user = &u 4335 } 4336 4337 // UserID returns the value of the "user_id" field in the mutation. 4338 func (m *SubscriptionMutation) UserID() (r uuid.UUID, exists bool) { 4339 v := m.user 4340 if v == nil { 4341 return 4342 } 4343 return *v, true 4344 } 4345 4346 // OldUserID returns the old "user_id" field's value of the Subscription entity. 4347 // If the Subscription object wasn't provided to the builder, the object is fetched from the database. 4348 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 4349 func (m *SubscriptionMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { 4350 if !m.op.Is(OpUpdateOne) { 4351 return v, errors.New("OldUserID is only allowed on UpdateOne operations") 4352 } 4353 if m.id == nil || m.oldValue == nil { 4354 return v, errors.New("OldUserID requires an ID field in the mutation") 4355 } 4356 oldValue, err := m.oldValue(ctx) 4357 if err != nil { 4358 return v, fmt.Errorf("querying old value for OldUserID: %w", err) 4359 } 4360 return oldValue.UserID, nil 4361 } 4362 4363 // ResetUserID resets all changes to the "user_id" field. 4364 func (m *SubscriptionMutation) ResetUserID() { 4365 m.user = nil 4366 } 4367 4368 // SetFeedID sets the "feed_id" field. 4369 func (m *SubscriptionMutation) SetFeedID(u uuid.UUID) { 4370 m.feed = &u 4371 } 4372 4373 // FeedID returns the value of the "feed_id" field in the mutation. 4374 func (m *SubscriptionMutation) FeedID() (r uuid.UUID, exists bool) { 4375 v := m.feed 4376 if v == nil { 4377 return 4378 } 4379 return *v, true 4380 } 4381 4382 // OldFeedID returns the old "feed_id" field's value of the Subscription entity. 4383 // If the Subscription object wasn't provided to the builder, the object is fetched from the database. 4384 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 4385 func (m *SubscriptionMutation) OldFeedID(ctx context.Context) (v uuid.UUID, err error) { 4386 if !m.op.Is(OpUpdateOne) { 4387 return v, errors.New("OldFeedID is only allowed on UpdateOne operations") 4388 } 4389 if m.id == nil || m.oldValue == nil { 4390 return v, errors.New("OldFeedID requires an ID field in the mutation") 4391 } 4392 oldValue, err := m.oldValue(ctx) 4393 if err != nil { 4394 return v, fmt.Errorf("querying old value for OldFeedID: %w", err) 4395 } 4396 return oldValue.FeedID, nil 4397 } 4398 4399 // ResetFeedID resets all changes to the "feed_id" field. 4400 func (m *SubscriptionMutation) ResetFeedID() { 4401 m.feed = nil 4402 } 4403 4404 // SetName sets the "name" field. 4405 func (m *SubscriptionMutation) SetName(s string) { 4406 m.name = &s 4407 } 4408 4409 // Name returns the value of the "name" field in the mutation. 4410 func (m *SubscriptionMutation) Name() (r string, exists bool) { 4411 v := m.name 4412 if v == nil { 4413 return 4414 } 4415 return *v, true 4416 } 4417 4418 // OldName returns the old "name" field's value of the Subscription entity. 4419 // If the Subscription object wasn't provided to the builder, the object is fetched from the database. 4420 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 4421 func (m *SubscriptionMutation) OldName(ctx context.Context) (v string, err error) { 4422 if !m.op.Is(OpUpdateOne) { 4423 return v, errors.New("OldName is only allowed on UpdateOne operations") 4424 } 4425 if m.id == nil || m.oldValue == nil { 4426 return v, errors.New("OldName requires an ID field in the mutation") 4427 } 4428 oldValue, err := m.oldValue(ctx) 4429 if err != nil { 4430 return v, fmt.Errorf("querying old value for OldName: %w", err) 4431 } 4432 return oldValue.Name, nil 4433 } 4434 4435 // ResetName resets all changes to the "name" field. 4436 func (m *SubscriptionMutation) ResetName() { 4437 m.name = nil 4438 } 4439 4440 // SetGroup sets the "group" field. 4441 func (m *SubscriptionMutation) SetGroup(s string) { 4442 m.group = &s 4443 } 4444 4445 // Group returns the value of the "group" field in the mutation. 4446 func (m *SubscriptionMutation) Group() (r string, exists bool) { 4447 v := m.group 4448 if v == nil { 4449 return 4450 } 4451 return *v, true 4452 } 4453 4454 // OldGroup returns the old "group" field's value of the Subscription entity. 4455 // If the Subscription object wasn't provided to the builder, the object is fetched from the database. 4456 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 4457 func (m *SubscriptionMutation) OldGroup(ctx context.Context) (v string, err error) { 4458 if !m.op.Is(OpUpdateOne) { 4459 return v, errors.New("OldGroup is only allowed on UpdateOne operations") 4460 } 4461 if m.id == nil || m.oldValue == nil { 4462 return v, errors.New("OldGroup requires an ID field in the mutation") 4463 } 4464 oldValue, err := m.oldValue(ctx) 4465 if err != nil { 4466 return v, fmt.Errorf("querying old value for OldGroup: %w", err) 4467 } 4468 return oldValue.Group, nil 4469 } 4470 4471 // ResetGroup resets all changes to the "group" field. 4472 func (m *SubscriptionMutation) ResetGroup() { 4473 m.group = nil 4474 } 4475 4476 // SetCreatedAt sets the "created_at" field. 4477 func (m *SubscriptionMutation) SetCreatedAt(t time.Time) { 4478 m.created_at = &t 4479 } 4480 4481 // CreatedAt returns the value of the "created_at" field in the mutation. 4482 func (m *SubscriptionMutation) CreatedAt() (r time.Time, exists bool) { 4483 v := m.created_at 4484 if v == nil { 4485 return 4486 } 4487 return *v, true 4488 } 4489 4490 // OldCreatedAt returns the old "created_at" field's value of the Subscription entity. 4491 // If the Subscription object wasn't provided to the builder, the object is fetched from the database. 4492 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 4493 func (m *SubscriptionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { 4494 if !m.op.Is(OpUpdateOne) { 4495 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 4496 } 4497 if m.id == nil || m.oldValue == nil { 4498 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 4499 } 4500 oldValue, err := m.oldValue(ctx) 4501 if err != nil { 4502 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 4503 } 4504 return oldValue.CreatedAt, nil 4505 } 4506 4507 // ResetCreatedAt resets all changes to the "created_at" field. 4508 func (m *SubscriptionMutation) ResetCreatedAt() { 4509 m.created_at = nil 4510 } 4511 4512 // ClearUser clears the "user" edge to the User entity. 4513 func (m *SubscriptionMutation) ClearUser() { 4514 m.cleareduser = true 4515 m.clearedFields[subscription.FieldUserID] = struct{}{} 4516 } 4517 4518 // UserCleared reports if the "user" edge to the User entity was cleared. 4519 func (m *SubscriptionMutation) UserCleared() bool { 4520 return m.cleareduser 4521 } 4522 4523 // UserIDs returns the "user" edge IDs in the mutation. 4524 // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use 4525 // UserID instead. It exists only for internal usage by the builders. 4526 func (m *SubscriptionMutation) UserIDs() (ids []uuid.UUID) { 4527 if id := m.user; id != nil { 4528 ids = append(ids, *id) 4529 } 4530 return 4531 } 4532 4533 // ResetUser resets all changes to the "user" edge. 4534 func (m *SubscriptionMutation) ResetUser() { 4535 m.user = nil 4536 m.cleareduser = false 4537 } 4538 4539 // ClearFeed clears the "feed" edge to the Feed entity. 4540 func (m *SubscriptionMutation) ClearFeed() { 4541 m.clearedfeed = true 4542 m.clearedFields[subscription.FieldFeedID] = struct{}{} 4543 } 4544 4545 // FeedCleared reports if the "feed" edge to the Feed entity was cleared. 4546 func (m *SubscriptionMutation) FeedCleared() bool { 4547 return m.clearedfeed 4548 } 4549 4550 // FeedIDs returns the "feed" edge IDs in the mutation. 4551 // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use 4552 // FeedID instead. It exists only for internal usage by the builders. 4553 func (m *SubscriptionMutation) FeedIDs() (ids []uuid.UUID) { 4554 if id := m.feed; id != nil { 4555 ids = append(ids, *id) 4556 } 4557 return 4558 } 4559 4560 // ResetFeed resets all changes to the "feed" edge. 4561 func (m *SubscriptionMutation) ResetFeed() { 4562 m.feed = nil 4563 m.clearedfeed = false 4564 } 4565 4566 // Where appends a list predicates to the SubscriptionMutation builder. 4567 func (m *SubscriptionMutation) Where(ps ...predicate.Subscription) { 4568 m.predicates = append(m.predicates, ps...) 4569 } 4570 4571 // WhereP appends storage-level predicates to the SubscriptionMutation builder. Using this method, 4572 // users can use type-assertion to append predicates that do not depend on any generated package. 4573 func (m *SubscriptionMutation) WhereP(ps ...func(*sql.Selector)) { 4574 p := make([]predicate.Subscription, len(ps)) 4575 for i := range ps { 4576 p[i] = ps[i] 4577 } 4578 m.Where(p...) 4579 } 4580 4581 // Op returns the operation name. 4582 func (m *SubscriptionMutation) Op() Op { 4583 return m.op 4584 } 4585 4586 // SetOp allows setting the mutation operation. 4587 func (m *SubscriptionMutation) SetOp(op Op) { 4588 m.op = op 4589 } 4590 4591 // Type returns the node type of this mutation (Subscription). 4592 func (m *SubscriptionMutation) Type() string { 4593 return m.typ 4594 } 4595 4596 // Fields returns all fields that were changed during this mutation. Note that in 4597 // order to get all numeric fields that were incremented/decremented, call 4598 // AddedFields(). 4599 func (m *SubscriptionMutation) Fields() []string { 4600 fields := make([]string, 0, 5) 4601 if m.user != nil { 4602 fields = append(fields, subscription.FieldUserID) 4603 } 4604 if m.feed != nil { 4605 fields = append(fields, subscription.FieldFeedID) 4606 } 4607 if m.name != nil { 4608 fields = append(fields, subscription.FieldName) 4609 } 4610 if m.group != nil { 4611 fields = append(fields, subscription.FieldGroup) 4612 } 4613 if m.created_at != nil { 4614 fields = append(fields, subscription.FieldCreatedAt) 4615 } 4616 return fields 4617 } 4618 4619 // Field returns the value of a field with the given name. The second boolean 4620 // return value indicates that this field was not set, or was not defined in the 4621 // schema. 4622 func (m *SubscriptionMutation) Field(name string) (ent.Value, bool) { 4623 switch name { 4624 case subscription.FieldUserID: 4625 return m.UserID() 4626 case subscription.FieldFeedID: 4627 return m.FeedID() 4628 case subscription.FieldName: 4629 return m.Name() 4630 case subscription.FieldGroup: 4631 return m.Group() 4632 case subscription.FieldCreatedAt: 4633 return m.CreatedAt() 4634 } 4635 return nil, false 4636 } 4637 4638 // OldField returns the old value of the field from the database. An error is 4639 // returned if the mutation operation is not UpdateOne, or the query to the 4640 // database failed. 4641 func (m *SubscriptionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 4642 switch name { 4643 case subscription.FieldUserID: 4644 return m.OldUserID(ctx) 4645 case subscription.FieldFeedID: 4646 return m.OldFeedID(ctx) 4647 case subscription.FieldName: 4648 return m.OldName(ctx) 4649 case subscription.FieldGroup: 4650 return m.OldGroup(ctx) 4651 case subscription.FieldCreatedAt: 4652 return m.OldCreatedAt(ctx) 4653 } 4654 return nil, fmt.Errorf("unknown Subscription field %s", name) 4655 } 4656 4657 // SetField sets the value of a field with the given name. It returns an error if 4658 // the field is not defined in the schema, or if the type mismatched the field 4659 // type. 4660 func (m *SubscriptionMutation) SetField(name string, value ent.Value) error { 4661 switch name { 4662 case subscription.FieldUserID: 4663 v, ok := value.(uuid.UUID) 4664 if !ok { 4665 return fmt.Errorf("unexpected type %T for field %s", value, name) 4666 } 4667 m.SetUserID(v) 4668 return nil 4669 case subscription.FieldFeedID: 4670 v, ok := value.(uuid.UUID) 4671 if !ok { 4672 return fmt.Errorf("unexpected type %T for field %s", value, name) 4673 } 4674 m.SetFeedID(v) 4675 return nil 4676 case subscription.FieldName: 4677 v, ok := value.(string) 4678 if !ok { 4679 return fmt.Errorf("unexpected type %T for field %s", value, name) 4680 } 4681 m.SetName(v) 4682 return nil 4683 case subscription.FieldGroup: 4684 v, ok := value.(string) 4685 if !ok { 4686 return fmt.Errorf("unexpected type %T for field %s", value, name) 4687 } 4688 m.SetGroup(v) 4689 return nil 4690 case subscription.FieldCreatedAt: 4691 v, ok := value.(time.Time) 4692 if !ok { 4693 return fmt.Errorf("unexpected type %T for field %s", value, name) 4694 } 4695 m.SetCreatedAt(v) 4696 return nil 4697 } 4698 return fmt.Errorf("unknown Subscription field %s", name) 4699 } 4700 4701 // AddedFields returns all numeric fields that were incremented/decremented during 4702 // this mutation. 4703 func (m *SubscriptionMutation) AddedFields() []string { 4704 return nil 4705 } 4706 4707 // AddedField returns the numeric value that was incremented/decremented on a field 4708 // with the given name. The second boolean return value indicates that this field 4709 // was not set, or was not defined in the schema. 4710 func (m *SubscriptionMutation) AddedField(name string) (ent.Value, bool) { 4711 return nil, false 4712 } 4713 4714 // AddField adds the value to the field with the given name. It returns an error if 4715 // the field is not defined in the schema, or if the type mismatched the field 4716 // type. 4717 func (m *SubscriptionMutation) AddField(name string, value ent.Value) error { 4718 switch name { 4719 } 4720 return fmt.Errorf("unknown Subscription numeric field %s", name) 4721 } 4722 4723 // ClearedFields returns all nullable fields that were cleared during this 4724 // mutation. 4725 func (m *SubscriptionMutation) ClearedFields() []string { 4726 return nil 4727 } 4728 4729 // FieldCleared returns a boolean indicating if a field with the given name was 4730 // cleared in this mutation. 4731 func (m *SubscriptionMutation) FieldCleared(name string) bool { 4732 _, ok := m.clearedFields[name] 4733 return ok 4734 } 4735 4736 // ClearField clears the value of the field with the given name. It returns an 4737 // error if the field is not defined in the schema. 4738 func (m *SubscriptionMutation) ClearField(name string) error { 4739 return fmt.Errorf("unknown Subscription nullable field %s", name) 4740 } 4741 4742 // ResetField resets all changes in the mutation for the field with the given name. 4743 // It returns an error if the field is not defined in the schema. 4744 func (m *SubscriptionMutation) ResetField(name string) error { 4745 switch name { 4746 case subscription.FieldUserID: 4747 m.ResetUserID() 4748 return nil 4749 case subscription.FieldFeedID: 4750 m.ResetFeedID() 4751 return nil 4752 case subscription.FieldName: 4753 m.ResetName() 4754 return nil 4755 case subscription.FieldGroup: 4756 m.ResetGroup() 4757 return nil 4758 case subscription.FieldCreatedAt: 4759 m.ResetCreatedAt() 4760 return nil 4761 } 4762 return fmt.Errorf("unknown Subscription field %s", name) 4763 } 4764 4765 // AddedEdges returns all edge names that were set/added in this mutation. 4766 func (m *SubscriptionMutation) AddedEdges() []string { 4767 edges := make([]string, 0, 2) 4768 if m.user != nil { 4769 edges = append(edges, subscription.EdgeUser) 4770 } 4771 if m.feed != nil { 4772 edges = append(edges, subscription.EdgeFeed) 4773 } 4774 return edges 4775 } 4776 4777 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 4778 // name in this mutation. 4779 func (m *SubscriptionMutation) AddedIDs(name string) []ent.Value { 4780 switch name { 4781 case subscription.EdgeUser: 4782 if id := m.user; id != nil { 4783 return []ent.Value{*id} 4784 } 4785 case subscription.EdgeFeed: 4786 if id := m.feed; id != nil { 4787 return []ent.Value{*id} 4788 } 4789 } 4790 return nil 4791 } 4792 4793 // RemovedEdges returns all edge names that were removed in this mutation. 4794 func (m *SubscriptionMutation) RemovedEdges() []string { 4795 edges := make([]string, 0, 2) 4796 return edges 4797 } 4798 4799 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 4800 // the given name in this mutation. 4801 func (m *SubscriptionMutation) RemovedIDs(name string) []ent.Value { 4802 return nil 4803 } 4804 4805 // ClearedEdges returns all edge names that were cleared in this mutation. 4806 func (m *SubscriptionMutation) ClearedEdges() []string { 4807 edges := make([]string, 0, 2) 4808 if m.cleareduser { 4809 edges = append(edges, subscription.EdgeUser) 4810 } 4811 if m.clearedfeed { 4812 edges = append(edges, subscription.EdgeFeed) 4813 } 4814 return edges 4815 } 4816 4817 // EdgeCleared returns a boolean which indicates if the edge with the given name 4818 // was cleared in this mutation. 4819 func (m *SubscriptionMutation) EdgeCleared(name string) bool { 4820 switch name { 4821 case subscription.EdgeUser: 4822 return m.cleareduser 4823 case subscription.EdgeFeed: 4824 return m.clearedfeed 4825 } 4826 return false 4827 } 4828 4829 // ClearEdge clears the value of the edge with the given name. It returns an error 4830 // if that edge is not defined in the schema. 4831 func (m *SubscriptionMutation) ClearEdge(name string) error { 4832 switch name { 4833 case subscription.EdgeUser: 4834 m.ClearUser() 4835 return nil 4836 case subscription.EdgeFeed: 4837 m.ClearFeed() 4838 return nil 4839 } 4840 return fmt.Errorf("unknown Subscription unique edge %s", name) 4841 } 4842 4843 // ResetEdge resets all changes to the edge with the given name in this mutation. 4844 // It returns an error if the edge is not defined in the schema. 4845 func (m *SubscriptionMutation) ResetEdge(name string) error { 4846 switch name { 4847 case subscription.EdgeUser: 4848 m.ResetUser() 4849 return nil 4850 case subscription.EdgeFeed: 4851 m.ResetFeed() 4852 return nil 4853 } 4854 return fmt.Errorf("unknown Subscription edge %s", name) 4855 } 4856 4857 // TokenMutation represents an operation that mutates the Token nodes in the graph. 4858 type TokenMutation struct { 4859 config 4860 op Op 4861 typ string 4862 id *uuid.UUID 4863 _type *string 4864 name *string 4865 token *string 4866 created_at *time.Time 4867 updated_at *time.Time 4868 deleted_at *time.Time 4869 clearedFields map[string]struct{} 4870 owner *uuid.UUID 4871 clearedowner bool 4872 done bool 4873 oldValue func(context.Context) (*Token, error) 4874 predicates []predicate.Token 4875 } 4876 4877 var _ ent.Mutation = (*TokenMutation)(nil) 4878 4879 // tokenOption allows management of the mutation configuration using functional options. 4880 type tokenOption func(*TokenMutation) 4881 4882 // newTokenMutation creates new mutation for the Token entity. 4883 func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation { 4884 m := &TokenMutation{ 4885 config: c, 4886 op: op, 4887 typ: TypeToken, 4888 clearedFields: make(map[string]struct{}), 4889 } 4890 for _, opt := range opts { 4891 opt(m) 4892 } 4893 return m 4894 } 4895 4896 // withTokenID sets the ID field of the mutation. 4897 func withTokenID(id uuid.UUID) tokenOption { 4898 return func(m *TokenMutation) { 4899 var ( 4900 err error 4901 once sync.Once 4902 value *Token 4903 ) 4904 m.oldValue = func(ctx context.Context) (*Token, error) { 4905 once.Do(func() { 4906 if m.done { 4907 err = errors.New("querying old values post mutation is not allowed") 4908 } else { 4909 value, err = m.Client().Token.Get(ctx, id) 4910 } 4911 }) 4912 return value, err 4913 } 4914 m.id = &id 4915 } 4916 } 4917 4918 // withToken sets the old Token of the mutation. 4919 func withToken(node *Token) tokenOption { 4920 return func(m *TokenMutation) { 4921 m.oldValue = func(context.Context) (*Token, error) { 4922 return node, nil 4923 } 4924 m.id = &node.ID 4925 } 4926 } 4927 4928 // Client returns a new `ent.Client` from the mutation. If the mutation was 4929 // executed in a transaction (ent.Tx), a transactional client is returned. 4930 func (m TokenMutation) Client() *Client { 4931 client := &Client{config: m.config} 4932 client.init() 4933 return client 4934 } 4935 4936 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 4937 // it returns an error otherwise. 4938 func (m TokenMutation) Tx() (*Tx, error) { 4939 if _, ok := m.driver.(*txDriver); !ok { 4940 return nil, errors.New("ent: mutation is not running in a transaction") 4941 } 4942 tx := &Tx{config: m.config} 4943 tx.init() 4944 return tx, nil 4945 } 4946 4947 // SetID sets the value of the id field. Note that this 4948 // operation is only accepted on creation of Token entities. 4949 func (m *TokenMutation) SetID(id uuid.UUID) { 4950 m.id = &id 4951 } 4952 4953 // ID returns the ID value in the mutation. Note that the ID is only available 4954 // if it was provided to the builder or after it was returned from the database. 4955 func (m *TokenMutation) ID() (id uuid.UUID, exists bool) { 4956 if m.id == nil { 4957 return 4958 } 4959 return *m.id, true 4960 } 4961 4962 // IDs queries the database and returns the entity ids that match the mutation's predicate. 4963 // That means, if the mutation is applied within a transaction with an isolation level such 4964 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 4965 // or updated by the mutation. 4966 func (m *TokenMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { 4967 switch { 4968 case m.op.Is(OpUpdateOne | OpDeleteOne): 4969 id, exists := m.ID() 4970 if exists { 4971 return []uuid.UUID{id}, nil 4972 } 4973 fallthrough 4974 case m.op.Is(OpUpdate | OpDelete): 4975 return m.Client().Token.Query().Where(m.predicates...).IDs(ctx) 4976 default: 4977 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 4978 } 4979 } 4980 4981 // SetType sets the "type" field. 4982 func (m *TokenMutation) SetType(s string) { 4983 m._type = &s 4984 } 4985 4986 // GetType returns the value of the "type" field in the mutation. 4987 func (m *TokenMutation) GetType() (r string, exists bool) { 4988 v := m._type 4989 if v == nil { 4990 return 4991 } 4992 return *v, true 4993 } 4994 4995 // OldType returns the old "type" field's value of the Token entity. 4996 // If the Token object wasn't provided to the builder, the object is fetched from the database. 4997 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 4998 func (m *TokenMutation) OldType(ctx context.Context) (v string, err error) { 4999 if !m.op.Is(OpUpdateOne) { 5000 return v, errors.New("OldType is only allowed on UpdateOne operations") 5001 } 5002 if m.id == nil || m.oldValue == nil { 5003 return v, errors.New("OldType requires an ID field in the mutation") 5004 } 5005 oldValue, err := m.oldValue(ctx) 5006 if err != nil { 5007 return v, fmt.Errorf("querying old value for OldType: %w", err) 5008 } 5009 return oldValue.Type, nil 5010 } 5011 5012 // ResetType resets all changes to the "type" field. 5013 func (m *TokenMutation) ResetType() { 5014 m._type = nil 5015 } 5016 5017 // SetName sets the "name" field. 5018 func (m *TokenMutation) SetName(s string) { 5019 m.name = &s 5020 } 5021 5022 // Name returns the value of the "name" field in the mutation. 5023 func (m *TokenMutation) Name() (r string, exists bool) { 5024 v := m.name 5025 if v == nil { 5026 return 5027 } 5028 return *v, true 5029 } 5030 5031 // OldName returns the old "name" field's value of the Token entity. 5032 // If the Token object wasn't provided to the builder, the object is fetched from the database. 5033 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 5034 func (m *TokenMutation) OldName(ctx context.Context) (v string, err error) { 5035 if !m.op.Is(OpUpdateOne) { 5036 return v, errors.New("OldName is only allowed on UpdateOne operations") 5037 } 5038 if m.id == nil || m.oldValue == nil { 5039 return v, errors.New("OldName requires an ID field in the mutation") 5040 } 5041 oldValue, err := m.oldValue(ctx) 5042 if err != nil { 5043 return v, fmt.Errorf("querying old value for OldName: %w", err) 5044 } 5045 return oldValue.Name, nil 5046 } 5047 5048 // ResetName resets all changes to the "name" field. 5049 func (m *TokenMutation) ResetName() { 5050 m.name = nil 5051 } 5052 5053 // SetToken sets the "token" field. 5054 func (m *TokenMutation) SetToken(s string) { 5055 m.token = &s 5056 } 5057 5058 // Token returns the value of the "token" field in the mutation. 5059 func (m *TokenMutation) Token() (r string, exists bool) { 5060 v := m.token 5061 if v == nil { 5062 return 5063 } 5064 return *v, true 5065 } 5066 5067 // OldToken returns the old "token" field's value of the Token entity. 5068 // If the Token object wasn't provided to the builder, the object is fetched from the database. 5069 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 5070 func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) { 5071 if !m.op.Is(OpUpdateOne) { 5072 return v, errors.New("OldToken is only allowed on UpdateOne operations") 5073 } 5074 if m.id == nil || m.oldValue == nil { 5075 return v, errors.New("OldToken requires an ID field in the mutation") 5076 } 5077 oldValue, err := m.oldValue(ctx) 5078 if err != nil { 5079 return v, fmt.Errorf("querying old value for OldToken: %w", err) 5080 } 5081 return oldValue.Token, nil 5082 } 5083 5084 // ResetToken resets all changes to the "token" field. 5085 func (m *TokenMutation) ResetToken() { 5086 m.token = nil 5087 } 5088 5089 // SetCreatedAt sets the "created_at" field. 5090 func (m *TokenMutation) SetCreatedAt(t time.Time) { 5091 m.created_at = &t 5092 } 5093 5094 // CreatedAt returns the value of the "created_at" field in the mutation. 5095 func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) { 5096 v := m.created_at 5097 if v == nil { 5098 return 5099 } 5100 return *v, true 5101 } 5102 5103 // OldCreatedAt returns the old "created_at" field's value of the Token entity. 5104 // If the Token object wasn't provided to the builder, the object is fetched from the database. 5105 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 5106 func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { 5107 if !m.op.Is(OpUpdateOne) { 5108 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 5109 } 5110 if m.id == nil || m.oldValue == nil { 5111 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 5112 } 5113 oldValue, err := m.oldValue(ctx) 5114 if err != nil { 5115 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 5116 } 5117 return oldValue.CreatedAt, nil 5118 } 5119 5120 // ResetCreatedAt resets all changes to the "created_at" field. 5121 func (m *TokenMutation) ResetCreatedAt() { 5122 m.created_at = nil 5123 } 5124 5125 // SetUpdatedAt sets the "updated_at" field. 5126 func (m *TokenMutation) SetUpdatedAt(t time.Time) { 5127 m.updated_at = &t 5128 } 5129 5130 // UpdatedAt returns the value of the "updated_at" field in the mutation. 5131 func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) { 5132 v := m.updated_at 5133 if v == nil { 5134 return 5135 } 5136 return *v, true 5137 } 5138 5139 // OldUpdatedAt returns the old "updated_at" field's value of the Token entity. 5140 // If the Token object wasn't provided to the builder, the object is fetched from the database. 5141 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 5142 func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { 5143 if !m.op.Is(OpUpdateOne) { 5144 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 5145 } 5146 if m.id == nil || m.oldValue == nil { 5147 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 5148 } 5149 oldValue, err := m.oldValue(ctx) 5150 if err != nil { 5151 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 5152 } 5153 return oldValue.UpdatedAt, nil 5154 } 5155 5156 // ResetUpdatedAt resets all changes to the "updated_at" field. 5157 func (m *TokenMutation) ResetUpdatedAt() { 5158 m.updated_at = nil 5159 } 5160 5161 // SetDeletedAt sets the "deleted_at" field. 5162 func (m *TokenMutation) SetDeletedAt(t time.Time) { 5163 m.deleted_at = &t 5164 } 5165 5166 // DeletedAt returns the value of the "deleted_at" field in the mutation. 5167 func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) { 5168 v := m.deleted_at 5169 if v == nil { 5170 return 5171 } 5172 return *v, true 5173 } 5174 5175 // OldDeletedAt returns the old "deleted_at" field's value of the Token entity. 5176 // If the Token object wasn't provided to the builder, the object is fetched from the database. 5177 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 5178 func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) { 5179 if !m.op.Is(OpUpdateOne) { 5180 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 5181 } 5182 if m.id == nil || m.oldValue == nil { 5183 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 5184 } 5185 oldValue, err := m.oldValue(ctx) 5186 if err != nil { 5187 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 5188 } 5189 return oldValue.DeletedAt, nil 5190 } 5191 5192 // ClearDeletedAt clears the value of the "deleted_at" field. 5193 func (m *TokenMutation) ClearDeletedAt() { 5194 m.deleted_at = nil 5195 m.clearedFields[token.FieldDeletedAt] = struct{}{} 5196 } 5197 5198 // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. 5199 func (m *TokenMutation) DeletedAtCleared() bool { 5200 _, ok := m.clearedFields[token.FieldDeletedAt] 5201 return ok 5202 } 5203 5204 // ResetDeletedAt resets all changes to the "deleted_at" field. 5205 func (m *TokenMutation) ResetDeletedAt() { 5206 m.deleted_at = nil 5207 delete(m.clearedFields, token.FieldDeletedAt) 5208 } 5209 5210 // SetOwnerID sets the "owner" edge to the User entity by id. 5211 func (m *TokenMutation) SetOwnerID(id uuid.UUID) { 5212 m.owner = &id 5213 } 5214 5215 // ClearOwner clears the "owner" edge to the User entity. 5216 func (m *TokenMutation) ClearOwner() { 5217 m.clearedowner = true 5218 } 5219 5220 // OwnerCleared reports if the "owner" edge to the User entity was cleared. 5221 func (m *TokenMutation) OwnerCleared() bool { 5222 return m.clearedowner 5223 } 5224 5225 // OwnerID returns the "owner" edge ID in the mutation. 5226 func (m *TokenMutation) OwnerID() (id uuid.UUID, exists bool) { 5227 if m.owner != nil { 5228 return *m.owner, true 5229 } 5230 return 5231 } 5232 5233 // OwnerIDs returns the "owner" edge IDs in the mutation. 5234 // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use 5235 // OwnerID instead. It exists only for internal usage by the builders. 5236 func (m *TokenMutation) OwnerIDs() (ids []uuid.UUID) { 5237 if id := m.owner; id != nil { 5238 ids = append(ids, *id) 5239 } 5240 return 5241 } 5242 5243 // ResetOwner resets all changes to the "owner" edge. 5244 func (m *TokenMutation) ResetOwner() { 5245 m.owner = nil 5246 m.clearedowner = false 5247 } 5248 5249 // Where appends a list predicates to the TokenMutation builder. 5250 func (m *TokenMutation) Where(ps ...predicate.Token) { 5251 m.predicates = append(m.predicates, ps...) 5252 } 5253 5254 // WhereP appends storage-level predicates to the TokenMutation builder. Using this method, 5255 // users can use type-assertion to append predicates that do not depend on any generated package. 5256 func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) { 5257 p := make([]predicate.Token, len(ps)) 5258 for i := range ps { 5259 p[i] = ps[i] 5260 } 5261 m.Where(p...) 5262 } 5263 5264 // Op returns the operation name. 5265 func (m *TokenMutation) Op() Op { 5266 return m.op 5267 } 5268 5269 // SetOp allows setting the mutation operation. 5270 func (m *TokenMutation) SetOp(op Op) { 5271 m.op = op 5272 } 5273 5274 // Type returns the node type of this mutation (Token). 5275 func (m *TokenMutation) Type() string { 5276 return m.typ 5277 } 5278 5279 // Fields returns all fields that were changed during this mutation. Note that in 5280 // order to get all numeric fields that were incremented/decremented, call 5281 // AddedFields(). 5282 func (m *TokenMutation) Fields() []string { 5283 fields := make([]string, 0, 6) 5284 if m._type != nil { 5285 fields = append(fields, token.FieldType) 5286 } 5287 if m.name != nil { 5288 fields = append(fields, token.FieldName) 5289 } 5290 if m.token != nil { 5291 fields = append(fields, token.FieldToken) 5292 } 5293 if m.created_at != nil { 5294 fields = append(fields, token.FieldCreatedAt) 5295 } 5296 if m.updated_at != nil { 5297 fields = append(fields, token.FieldUpdatedAt) 5298 } 5299 if m.deleted_at != nil { 5300 fields = append(fields, token.FieldDeletedAt) 5301 } 5302 return fields 5303 } 5304 5305 // Field returns the value of a field with the given name. The second boolean 5306 // return value indicates that this field was not set, or was not defined in the 5307 // schema. 5308 func (m *TokenMutation) Field(name string) (ent.Value, bool) { 5309 switch name { 5310 case token.FieldType: 5311 return m.GetType() 5312 case token.FieldName: 5313 return m.Name() 5314 case token.FieldToken: 5315 return m.Token() 5316 case token.FieldCreatedAt: 5317 return m.CreatedAt() 5318 case token.FieldUpdatedAt: 5319 return m.UpdatedAt() 5320 case token.FieldDeletedAt: 5321 return m.DeletedAt() 5322 } 5323 return nil, false 5324 } 5325 5326 // OldField returns the old value of the field from the database. An error is 5327 // returned if the mutation operation is not UpdateOne, or the query to the 5328 // database failed. 5329 func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 5330 switch name { 5331 case token.FieldType: 5332 return m.OldType(ctx) 5333 case token.FieldName: 5334 return m.OldName(ctx) 5335 case token.FieldToken: 5336 return m.OldToken(ctx) 5337 case token.FieldCreatedAt: 5338 return m.OldCreatedAt(ctx) 5339 case token.FieldUpdatedAt: 5340 return m.OldUpdatedAt(ctx) 5341 case token.FieldDeletedAt: 5342 return m.OldDeletedAt(ctx) 5343 } 5344 return nil, fmt.Errorf("unknown Token field %s", name) 5345 } 5346 5347 // SetField sets the value of a field with the given name. It returns an error if 5348 // the field is not defined in the schema, or if the type mismatched the field 5349 // type. 5350 func (m *TokenMutation) SetField(name string, value ent.Value) error { 5351 switch name { 5352 case token.FieldType: 5353 v, ok := value.(string) 5354 if !ok { 5355 return fmt.Errorf("unexpected type %T for field %s", value, name) 5356 } 5357 m.SetType(v) 5358 return nil 5359 case token.FieldName: 5360 v, ok := value.(string) 5361 if !ok { 5362 return fmt.Errorf("unexpected type %T for field %s", value, name) 5363 } 5364 m.SetName(v) 5365 return nil 5366 case token.FieldToken: 5367 v, ok := value.(string) 5368 if !ok { 5369 return fmt.Errorf("unexpected type %T for field %s", value, name) 5370 } 5371 m.SetToken(v) 5372 return nil 5373 case token.FieldCreatedAt: 5374 v, ok := value.(time.Time) 5375 if !ok { 5376 return fmt.Errorf("unexpected type %T for field %s", value, name) 5377 } 5378 m.SetCreatedAt(v) 5379 return nil 5380 case token.FieldUpdatedAt: 5381 v, ok := value.(time.Time) 5382 if !ok { 5383 return fmt.Errorf("unexpected type %T for field %s", value, name) 5384 } 5385 m.SetUpdatedAt(v) 5386 return nil 5387 case token.FieldDeletedAt: 5388 v, ok := value.(time.Time) 5389 if !ok { 5390 return fmt.Errorf("unexpected type %T for field %s", value, name) 5391 } 5392 m.SetDeletedAt(v) 5393 return nil 5394 } 5395 return fmt.Errorf("unknown Token field %s", name) 5396 } 5397 5398 // AddedFields returns all numeric fields that were incremented/decremented during 5399 // this mutation. 5400 func (m *TokenMutation) AddedFields() []string { 5401 return nil 5402 } 5403 5404 // AddedField returns the numeric value that was incremented/decremented on a field 5405 // with the given name. The second boolean return value indicates that this field 5406 // was not set, or was not defined in the schema. 5407 func (m *TokenMutation) AddedField(name string) (ent.Value, bool) { 5408 return nil, false 5409 } 5410 5411 // AddField adds the value to the field with the given name. It returns an error if 5412 // the field is not defined in the schema, or if the type mismatched the field 5413 // type. 5414 func (m *TokenMutation) AddField(name string, value ent.Value) error { 5415 switch name { 5416 } 5417 return fmt.Errorf("unknown Token numeric field %s", name) 5418 } 5419 5420 // ClearedFields returns all nullable fields that were cleared during this 5421 // mutation. 5422 func (m *TokenMutation) ClearedFields() []string { 5423 var fields []string 5424 if m.FieldCleared(token.FieldDeletedAt) { 5425 fields = append(fields, token.FieldDeletedAt) 5426 } 5427 return fields 5428 } 5429 5430 // FieldCleared returns a boolean indicating if a field with the given name was 5431 // cleared in this mutation. 5432 func (m *TokenMutation) FieldCleared(name string) bool { 5433 _, ok := m.clearedFields[name] 5434 return ok 5435 } 5436 5437 // ClearField clears the value of the field with the given name. It returns an 5438 // error if the field is not defined in the schema. 5439 func (m *TokenMutation) ClearField(name string) error { 5440 switch name { 5441 case token.FieldDeletedAt: 5442 m.ClearDeletedAt() 5443 return nil 5444 } 5445 return fmt.Errorf("unknown Token nullable field %s", name) 5446 } 5447 5448 // ResetField resets all changes in the mutation for the field with the given name. 5449 // It returns an error if the field is not defined in the schema. 5450 func (m *TokenMutation) ResetField(name string) error { 5451 switch name { 5452 case token.FieldType: 5453 m.ResetType() 5454 return nil 5455 case token.FieldName: 5456 m.ResetName() 5457 return nil 5458 case token.FieldToken: 5459 m.ResetToken() 5460 return nil 5461 case token.FieldCreatedAt: 5462 m.ResetCreatedAt() 5463 return nil 5464 case token.FieldUpdatedAt: 5465 m.ResetUpdatedAt() 5466 return nil 5467 case token.FieldDeletedAt: 5468 m.ResetDeletedAt() 5469 return nil 5470 } 5471 return fmt.Errorf("unknown Token field %s", name) 5472 } 5473 5474 // AddedEdges returns all edge names that were set/added in this mutation. 5475 func (m *TokenMutation) AddedEdges() []string { 5476 edges := make([]string, 0, 1) 5477 if m.owner != nil { 5478 edges = append(edges, token.EdgeOwner) 5479 } 5480 return edges 5481 } 5482 5483 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 5484 // name in this mutation. 5485 func (m *TokenMutation) AddedIDs(name string) []ent.Value { 5486 switch name { 5487 case token.EdgeOwner: 5488 if id := m.owner; id != nil { 5489 return []ent.Value{*id} 5490 } 5491 } 5492 return nil 5493 } 5494 5495 // RemovedEdges returns all edge names that were removed in this mutation. 5496 func (m *TokenMutation) RemovedEdges() []string { 5497 edges := make([]string, 0, 1) 5498 return edges 5499 } 5500 5501 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 5502 // the given name in this mutation. 5503 func (m *TokenMutation) RemovedIDs(name string) []ent.Value { 5504 return nil 5505 } 5506 5507 // ClearedEdges returns all edge names that were cleared in this mutation. 5508 func (m *TokenMutation) ClearedEdges() []string { 5509 edges := make([]string, 0, 1) 5510 if m.clearedowner { 5511 edges = append(edges, token.EdgeOwner) 5512 } 5513 return edges 5514 } 5515 5516 // EdgeCleared returns a boolean which indicates if the edge with the given name 5517 // was cleared in this mutation. 5518 func (m *TokenMutation) EdgeCleared(name string) bool { 5519 switch name { 5520 case token.EdgeOwner: 5521 return m.clearedowner 5522 } 5523 return false 5524 } 5525 5526 // ClearEdge clears the value of the edge with the given name. It returns an error 5527 // if that edge is not defined in the schema. 5528 func (m *TokenMutation) ClearEdge(name string) error { 5529 switch name { 5530 case token.EdgeOwner: 5531 m.ClearOwner() 5532 return nil 5533 } 5534 return fmt.Errorf("unknown Token unique edge %s", name) 5535 } 5536 5537 // ResetEdge resets all changes to the edge with the given name in this mutation. 5538 // It returns an error if the edge is not defined in the schema. 5539 func (m *TokenMutation) ResetEdge(name string) error { 5540 switch name { 5541 case token.EdgeOwner: 5542 m.ResetOwner() 5543 return nil 5544 } 5545 return fmt.Errorf("unknown Token edge %s", name) 5546 } 5547 5548 // UserMutation represents an operation that mutates the User nodes in the graph. 5549 type UserMutation struct { 5550 config 5551 op Op 5552 typ string 5553 id *uuid.UUID 5554 username *string 5555 password *string 5556 role *string 5557 created_at *time.Time 5558 updated_at *time.Time 5559 deleted_at *time.Time 5560 clearedFields map[string]struct{} 5561 tokens map[uuid.UUID]struct{} 5562 removedtokens map[uuid.UUID]struct{} 5563 clearedtokens bool 5564 subscribed_feeds map[uuid.UUID]struct{} 5565 removedsubscribed_feeds map[uuid.UUID]struct{} 5566 clearedsubscribed_feeds bool 5567 read_items map[uuid.UUID]struct{} 5568 removedread_items map[uuid.UUID]struct{} 5569 clearedread_items bool 5570 subscriptions map[uuid.UUID]struct{} 5571 removedsubscriptions map[uuid.UUID]struct{} 5572 clearedsubscriptions bool 5573 reads map[uuid.UUID]struct{} 5574 removedreads map[uuid.UUID]struct{} 5575 clearedreads bool 5576 done bool 5577 oldValue func(context.Context) (*User, error) 5578 predicates []predicate.User 5579 } 5580 5581 var _ ent.Mutation = (*UserMutation)(nil) 5582 5583 // userOption allows management of the mutation configuration using functional options. 5584 type userOption func(*UserMutation) 5585 5586 // newUserMutation creates new mutation for the User entity. 5587 func newUserMutation(c config, op Op, opts ...userOption) *UserMutation { 5588 m := &UserMutation{ 5589 config: c, 5590 op: op, 5591 typ: TypeUser, 5592 clearedFields: make(map[string]struct{}), 5593 } 5594 for _, opt := range opts { 5595 opt(m) 5596 } 5597 return m 5598 } 5599 5600 // withUserID sets the ID field of the mutation. 5601 func withUserID(id uuid.UUID) userOption { 5602 return func(m *UserMutation) { 5603 var ( 5604 err error 5605 once sync.Once 5606 value *User 5607 ) 5608 m.oldValue = func(ctx context.Context) (*User, error) { 5609 once.Do(func() { 5610 if m.done { 5611 err = errors.New("querying old values post mutation is not allowed") 5612 } else { 5613 value, err = m.Client().User.Get(ctx, id) 5614 } 5615 }) 5616 return value, err 5617 } 5618 m.id = &id 5619 } 5620 } 5621 5622 // withUser sets the old User of the mutation. 5623 func withUser(node *User) userOption { 5624 return func(m *UserMutation) { 5625 m.oldValue = func(context.Context) (*User, error) { 5626 return node, nil 5627 } 5628 m.id = &node.ID 5629 } 5630 } 5631 5632 // Client returns a new `ent.Client` from the mutation. If the mutation was 5633 // executed in a transaction (ent.Tx), a transactional client is returned. 5634 func (m UserMutation) Client() *Client { 5635 client := &Client{config: m.config} 5636 client.init() 5637 return client 5638 } 5639 5640 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 5641 // it returns an error otherwise. 5642 func (m UserMutation) Tx() (*Tx, error) { 5643 if _, ok := m.driver.(*txDriver); !ok { 5644 return nil, errors.New("ent: mutation is not running in a transaction") 5645 } 5646 tx := &Tx{config: m.config} 5647 tx.init() 5648 return tx, nil 5649 } 5650 5651 // SetID sets the value of the id field. Note that this 5652 // operation is only accepted on creation of User entities. 5653 func (m *UserMutation) SetID(id uuid.UUID) { 5654 m.id = &id 5655 } 5656 5657 // ID returns the ID value in the mutation. Note that the ID is only available 5658 // if it was provided to the builder or after it was returned from the database. 5659 func (m *UserMutation) ID() (id uuid.UUID, exists bool) { 5660 if m.id == nil { 5661 return 5662 } 5663 return *m.id, true 5664 } 5665 5666 // IDs queries the database and returns the entity ids that match the mutation's predicate. 5667 // That means, if the mutation is applied within a transaction with an isolation level such 5668 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 5669 // or updated by the mutation. 5670 func (m *UserMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { 5671 switch { 5672 case m.op.Is(OpUpdateOne | OpDeleteOne): 5673 id, exists := m.ID() 5674 if exists { 5675 return []uuid.UUID{id}, nil 5676 } 5677 fallthrough 5678 case m.op.Is(OpUpdate | OpDelete): 5679 return m.Client().User.Query().Where(m.predicates...).IDs(ctx) 5680 default: 5681 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 5682 } 5683 } 5684 5685 // SetUsername sets the "username" field. 5686 func (m *UserMutation) SetUsername(s string) { 5687 m.username = &s 5688 } 5689 5690 // Username returns the value of the "username" field in the mutation. 5691 func (m *UserMutation) Username() (r string, exists bool) { 5692 v := m.username 5693 if v == nil { 5694 return 5695 } 5696 return *v, true 5697 } 5698 5699 // OldUsername returns the old "username" field's value of the User entity. 5700 // If the User object wasn't provided to the builder, the object is fetched from the database. 5701 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 5702 func (m *UserMutation) OldUsername(ctx context.Context) (v string, err error) { 5703 if !m.op.Is(OpUpdateOne) { 5704 return v, errors.New("OldUsername is only allowed on UpdateOne operations") 5705 } 5706 if m.id == nil || m.oldValue == nil { 5707 return v, errors.New("OldUsername requires an ID field in the mutation") 5708 } 5709 oldValue, err := m.oldValue(ctx) 5710 if err != nil { 5711 return v, fmt.Errorf("querying old value for OldUsername: %w", err) 5712 } 5713 return oldValue.Username, nil 5714 } 5715 5716 // ResetUsername resets all changes to the "username" field. 5717 func (m *UserMutation) ResetUsername() { 5718 m.username = nil 5719 } 5720 5721 // SetPassword sets the "password" field. 5722 func (m *UserMutation) SetPassword(s string) { 5723 m.password = &s 5724 } 5725 5726 // Password returns the value of the "password" field in the mutation. 5727 func (m *UserMutation) Password() (r string, exists bool) { 5728 v := m.password 5729 if v == nil { 5730 return 5731 } 5732 return *v, true 5733 } 5734 5735 // OldPassword returns the old "password" field's value of the User entity. 5736 // If the User object wasn't provided to the builder, the object is fetched from the database. 5737 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 5738 func (m *UserMutation) OldPassword(ctx context.Context) (v string, err error) { 5739 if !m.op.Is(OpUpdateOne) { 5740 return v, errors.New("OldPassword is only allowed on UpdateOne operations") 5741 } 5742 if m.id == nil || m.oldValue == nil { 5743 return v, errors.New("OldPassword requires an ID field in the mutation") 5744 } 5745 oldValue, err := m.oldValue(ctx) 5746 if err != nil { 5747 return v, fmt.Errorf("querying old value for OldPassword: %w", err) 5748 } 5749 return oldValue.Password, nil 5750 } 5751 5752 // ResetPassword resets all changes to the "password" field. 5753 func (m *UserMutation) ResetPassword() { 5754 m.password = nil 5755 } 5756 5757 // SetRole sets the "role" field. 5758 func (m *UserMutation) SetRole(s string) { 5759 m.role = &s 5760 } 5761 5762 // Role returns the value of the "role" field in the mutation. 5763 func (m *UserMutation) Role() (r string, exists bool) { 5764 v := m.role 5765 if v == nil { 5766 return 5767 } 5768 return *v, true 5769 } 5770 5771 // OldRole returns the old "role" field's value of the User entity. 5772 // If the User object wasn't provided to the builder, the object is fetched from the database. 5773 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 5774 func (m *UserMutation) OldRole(ctx context.Context) (v string, err error) { 5775 if !m.op.Is(OpUpdateOne) { 5776 return v, errors.New("OldRole is only allowed on UpdateOne operations") 5777 } 5778 if m.id == nil || m.oldValue == nil { 5779 return v, errors.New("OldRole requires an ID field in the mutation") 5780 } 5781 oldValue, err := m.oldValue(ctx) 5782 if err != nil { 5783 return v, fmt.Errorf("querying old value for OldRole: %w", err) 5784 } 5785 return oldValue.Role, nil 5786 } 5787 5788 // ResetRole resets all changes to the "role" field. 5789 func (m *UserMutation) ResetRole() { 5790 m.role = nil 5791 } 5792 5793 // SetCreatedAt sets the "created_at" field. 5794 func (m *UserMutation) SetCreatedAt(t time.Time) { 5795 m.created_at = &t 5796 } 5797 5798 // CreatedAt returns the value of the "created_at" field in the mutation. 5799 func (m *UserMutation) CreatedAt() (r time.Time, exists bool) { 5800 v := m.created_at 5801 if v == nil { 5802 return 5803 } 5804 return *v, true 5805 } 5806 5807 // OldCreatedAt returns the old "created_at" field's value of the User entity. 5808 // If the User object wasn't provided to the builder, the object is fetched from the database. 5809 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 5810 func (m *UserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { 5811 if !m.op.Is(OpUpdateOne) { 5812 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 5813 } 5814 if m.id == nil || m.oldValue == nil { 5815 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 5816 } 5817 oldValue, err := m.oldValue(ctx) 5818 if err != nil { 5819 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 5820 } 5821 return oldValue.CreatedAt, nil 5822 } 5823 5824 // ResetCreatedAt resets all changes to the "created_at" field. 5825 func (m *UserMutation) ResetCreatedAt() { 5826 m.created_at = nil 5827 } 5828 5829 // SetUpdatedAt sets the "updated_at" field. 5830 func (m *UserMutation) SetUpdatedAt(t time.Time) { 5831 m.updated_at = &t 5832 } 5833 5834 // UpdatedAt returns the value of the "updated_at" field in the mutation. 5835 func (m *UserMutation) UpdatedAt() (r time.Time, exists bool) { 5836 v := m.updated_at 5837 if v == nil { 5838 return 5839 } 5840 return *v, true 5841 } 5842 5843 // OldUpdatedAt returns the old "updated_at" field's value of the User entity. 5844 // If the User object wasn't provided to the builder, the object is fetched from the database. 5845 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 5846 func (m *UserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { 5847 if !m.op.Is(OpUpdateOne) { 5848 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 5849 } 5850 if m.id == nil || m.oldValue == nil { 5851 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 5852 } 5853 oldValue, err := m.oldValue(ctx) 5854 if err != nil { 5855 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 5856 } 5857 return oldValue.UpdatedAt, nil 5858 } 5859 5860 // ResetUpdatedAt resets all changes to the "updated_at" field. 5861 func (m *UserMutation) ResetUpdatedAt() { 5862 m.updated_at = nil 5863 } 5864 5865 // SetDeletedAt sets the "deleted_at" field. 5866 func (m *UserMutation) SetDeletedAt(t time.Time) { 5867 m.deleted_at = &t 5868 } 5869 5870 // DeletedAt returns the value of the "deleted_at" field in the mutation. 5871 func (m *UserMutation) DeletedAt() (r time.Time, exists bool) { 5872 v := m.deleted_at 5873 if v == nil { 5874 return 5875 } 5876 return *v, true 5877 } 5878 5879 // OldDeletedAt returns the old "deleted_at" field's value of the User entity. 5880 // If the User object wasn't provided to the builder, the object is fetched from the database. 5881 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 5882 func (m *UserMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) { 5883 if !m.op.Is(OpUpdateOne) { 5884 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 5885 } 5886 if m.id == nil || m.oldValue == nil { 5887 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 5888 } 5889 oldValue, err := m.oldValue(ctx) 5890 if err != nil { 5891 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 5892 } 5893 return oldValue.DeletedAt, nil 5894 } 5895 5896 // ClearDeletedAt clears the value of the "deleted_at" field. 5897 func (m *UserMutation) ClearDeletedAt() { 5898 m.deleted_at = nil 5899 m.clearedFields[user.FieldDeletedAt] = struct{}{} 5900 } 5901 5902 // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. 5903 func (m *UserMutation) DeletedAtCleared() bool { 5904 _, ok := m.clearedFields[user.FieldDeletedAt] 5905 return ok 5906 } 5907 5908 // ResetDeletedAt resets all changes to the "deleted_at" field. 5909 func (m *UserMutation) ResetDeletedAt() { 5910 m.deleted_at = nil 5911 delete(m.clearedFields, user.FieldDeletedAt) 5912 } 5913 5914 // AddTokenIDs adds the "tokens" edge to the Token entity by ids. 5915 func (m *UserMutation) AddTokenIDs(ids ...uuid.UUID) { 5916 if m.tokens == nil { 5917 m.tokens = make(map[uuid.UUID]struct{}) 5918 } 5919 for i := range ids { 5920 m.tokens[ids[i]] = struct{}{} 5921 } 5922 } 5923 5924 // ClearTokens clears the "tokens" edge to the Token entity. 5925 func (m *UserMutation) ClearTokens() { 5926 m.clearedtokens = true 5927 } 5928 5929 // TokensCleared reports if the "tokens" edge to the Token entity was cleared. 5930 func (m *UserMutation) TokensCleared() bool { 5931 return m.clearedtokens 5932 } 5933 5934 // RemoveTokenIDs removes the "tokens" edge to the Token entity by IDs. 5935 func (m *UserMutation) RemoveTokenIDs(ids ...uuid.UUID) { 5936 if m.removedtokens == nil { 5937 m.removedtokens = make(map[uuid.UUID]struct{}) 5938 } 5939 for i := range ids { 5940 delete(m.tokens, ids[i]) 5941 m.removedtokens[ids[i]] = struct{}{} 5942 } 5943 } 5944 5945 // RemovedTokens returns the removed IDs of the "tokens" edge to the Token entity. 5946 func (m *UserMutation) RemovedTokensIDs() (ids []uuid.UUID) { 5947 for id := range m.removedtokens { 5948 ids = append(ids, id) 5949 } 5950 return 5951 } 5952 5953 // TokensIDs returns the "tokens" edge IDs in the mutation. 5954 func (m *UserMutation) TokensIDs() (ids []uuid.UUID) { 5955 for id := range m.tokens { 5956 ids = append(ids, id) 5957 } 5958 return 5959 } 5960 5961 // ResetTokens resets all changes to the "tokens" edge. 5962 func (m *UserMutation) ResetTokens() { 5963 m.tokens = nil 5964 m.clearedtokens = false 5965 m.removedtokens = nil 5966 } 5967 5968 // AddSubscribedFeedIDs adds the "subscribed_feeds" edge to the Feed entity by ids. 5969 func (m *UserMutation) AddSubscribedFeedIDs(ids ...uuid.UUID) { 5970 if m.subscribed_feeds == nil { 5971 m.subscribed_feeds = make(map[uuid.UUID]struct{}) 5972 } 5973 for i := range ids { 5974 m.subscribed_feeds[ids[i]] = struct{}{} 5975 } 5976 } 5977 5978 // ClearSubscribedFeeds clears the "subscribed_feeds" edge to the Feed entity. 5979 func (m *UserMutation) ClearSubscribedFeeds() { 5980 m.clearedsubscribed_feeds = true 5981 } 5982 5983 // SubscribedFeedsCleared reports if the "subscribed_feeds" edge to the Feed entity was cleared. 5984 func (m *UserMutation) SubscribedFeedsCleared() bool { 5985 return m.clearedsubscribed_feeds 5986 } 5987 5988 // RemoveSubscribedFeedIDs removes the "subscribed_feeds" edge to the Feed entity by IDs. 5989 func (m *UserMutation) RemoveSubscribedFeedIDs(ids ...uuid.UUID) { 5990 if m.removedsubscribed_feeds == nil { 5991 m.removedsubscribed_feeds = make(map[uuid.UUID]struct{}) 5992 } 5993 for i := range ids { 5994 delete(m.subscribed_feeds, ids[i]) 5995 m.removedsubscribed_feeds[ids[i]] = struct{}{} 5996 } 5997 } 5998 5999 // RemovedSubscribedFeeds returns the removed IDs of the "subscribed_feeds" edge to the Feed entity. 6000 func (m *UserMutation) RemovedSubscribedFeedsIDs() (ids []uuid.UUID) { 6001 for id := range m.removedsubscribed_feeds { 6002 ids = append(ids, id) 6003 } 6004 return 6005 } 6006 6007 // SubscribedFeedsIDs returns the "subscribed_feeds" edge IDs in the mutation. 6008 func (m *UserMutation) SubscribedFeedsIDs() (ids []uuid.UUID) { 6009 for id := range m.subscribed_feeds { 6010 ids = append(ids, id) 6011 } 6012 return 6013 } 6014 6015 // ResetSubscribedFeeds resets all changes to the "subscribed_feeds" edge. 6016 func (m *UserMutation) ResetSubscribedFeeds() { 6017 m.subscribed_feeds = nil 6018 m.clearedsubscribed_feeds = false 6019 m.removedsubscribed_feeds = nil 6020 } 6021 6022 // AddReadItemIDs adds the "read_items" edge to the Item entity by ids. 6023 func (m *UserMutation) AddReadItemIDs(ids ...uuid.UUID) { 6024 if m.read_items == nil { 6025 m.read_items = make(map[uuid.UUID]struct{}) 6026 } 6027 for i := range ids { 6028 m.read_items[ids[i]] = struct{}{} 6029 } 6030 } 6031 6032 // ClearReadItems clears the "read_items" edge to the Item entity. 6033 func (m *UserMutation) ClearReadItems() { 6034 m.clearedread_items = true 6035 } 6036 6037 // ReadItemsCleared reports if the "read_items" edge to the Item entity was cleared. 6038 func (m *UserMutation) ReadItemsCleared() bool { 6039 return m.clearedread_items 6040 } 6041 6042 // RemoveReadItemIDs removes the "read_items" edge to the Item entity by IDs. 6043 func (m *UserMutation) RemoveReadItemIDs(ids ...uuid.UUID) { 6044 if m.removedread_items == nil { 6045 m.removedread_items = make(map[uuid.UUID]struct{}) 6046 } 6047 for i := range ids { 6048 delete(m.read_items, ids[i]) 6049 m.removedread_items[ids[i]] = struct{}{} 6050 } 6051 } 6052 6053 // RemovedReadItems returns the removed IDs of the "read_items" edge to the Item entity. 6054 func (m *UserMutation) RemovedReadItemsIDs() (ids []uuid.UUID) { 6055 for id := range m.removedread_items { 6056 ids = append(ids, id) 6057 } 6058 return 6059 } 6060 6061 // ReadItemsIDs returns the "read_items" edge IDs in the mutation. 6062 func (m *UserMutation) ReadItemsIDs() (ids []uuid.UUID) { 6063 for id := range m.read_items { 6064 ids = append(ids, id) 6065 } 6066 return 6067 } 6068 6069 // ResetReadItems resets all changes to the "read_items" edge. 6070 func (m *UserMutation) ResetReadItems() { 6071 m.read_items = nil 6072 m.clearedread_items = false 6073 m.removedread_items = nil 6074 } 6075 6076 // AddSubscriptionIDs adds the "subscriptions" edge to the Subscription entity by ids. 6077 func (m *UserMutation) AddSubscriptionIDs(ids ...uuid.UUID) { 6078 if m.subscriptions == nil { 6079 m.subscriptions = make(map[uuid.UUID]struct{}) 6080 } 6081 for i := range ids { 6082 m.subscriptions[ids[i]] = struct{}{} 6083 } 6084 } 6085 6086 // ClearSubscriptions clears the "subscriptions" edge to the Subscription entity. 6087 func (m *UserMutation) ClearSubscriptions() { 6088 m.clearedsubscriptions = true 6089 } 6090 6091 // SubscriptionsCleared reports if the "subscriptions" edge to the Subscription entity was cleared. 6092 func (m *UserMutation) SubscriptionsCleared() bool { 6093 return m.clearedsubscriptions 6094 } 6095 6096 // RemoveSubscriptionIDs removes the "subscriptions" edge to the Subscription entity by IDs. 6097 func (m *UserMutation) RemoveSubscriptionIDs(ids ...uuid.UUID) { 6098 if m.removedsubscriptions == nil { 6099 m.removedsubscriptions = make(map[uuid.UUID]struct{}) 6100 } 6101 for i := range ids { 6102 delete(m.subscriptions, ids[i]) 6103 m.removedsubscriptions[ids[i]] = struct{}{} 6104 } 6105 } 6106 6107 // RemovedSubscriptions returns the removed IDs of the "subscriptions" edge to the Subscription entity. 6108 func (m *UserMutation) RemovedSubscriptionsIDs() (ids []uuid.UUID) { 6109 for id := range m.removedsubscriptions { 6110 ids = append(ids, id) 6111 } 6112 return 6113 } 6114 6115 // SubscriptionsIDs returns the "subscriptions" edge IDs in the mutation. 6116 func (m *UserMutation) SubscriptionsIDs() (ids []uuid.UUID) { 6117 for id := range m.subscriptions { 6118 ids = append(ids, id) 6119 } 6120 return 6121 } 6122 6123 // ResetSubscriptions resets all changes to the "subscriptions" edge. 6124 func (m *UserMutation) ResetSubscriptions() { 6125 m.subscriptions = nil 6126 m.clearedsubscriptions = false 6127 m.removedsubscriptions = nil 6128 } 6129 6130 // AddReadIDs adds the "reads" edge to the Read entity by ids. 6131 func (m *UserMutation) AddReadIDs(ids ...uuid.UUID) { 6132 if m.reads == nil { 6133 m.reads = make(map[uuid.UUID]struct{}) 6134 } 6135 for i := range ids { 6136 m.reads[ids[i]] = struct{}{} 6137 } 6138 } 6139 6140 // ClearReads clears the "reads" edge to the Read entity. 6141 func (m *UserMutation) ClearReads() { 6142 m.clearedreads = true 6143 } 6144 6145 // ReadsCleared reports if the "reads" edge to the Read entity was cleared. 6146 func (m *UserMutation) ReadsCleared() bool { 6147 return m.clearedreads 6148 } 6149 6150 // RemoveReadIDs removes the "reads" edge to the Read entity by IDs. 6151 func (m *UserMutation) RemoveReadIDs(ids ...uuid.UUID) { 6152 if m.removedreads == nil { 6153 m.removedreads = make(map[uuid.UUID]struct{}) 6154 } 6155 for i := range ids { 6156 delete(m.reads, ids[i]) 6157 m.removedreads[ids[i]] = struct{}{} 6158 } 6159 } 6160 6161 // RemovedReads returns the removed IDs of the "reads" edge to the Read entity. 6162 func (m *UserMutation) RemovedReadsIDs() (ids []uuid.UUID) { 6163 for id := range m.removedreads { 6164 ids = append(ids, id) 6165 } 6166 return 6167 } 6168 6169 // ReadsIDs returns the "reads" edge IDs in the mutation. 6170 func (m *UserMutation) ReadsIDs() (ids []uuid.UUID) { 6171 for id := range m.reads { 6172 ids = append(ids, id) 6173 } 6174 return 6175 } 6176 6177 // ResetReads resets all changes to the "reads" edge. 6178 func (m *UserMutation) ResetReads() { 6179 m.reads = nil 6180 m.clearedreads = false 6181 m.removedreads = nil 6182 } 6183 6184 // Where appends a list predicates to the UserMutation builder. 6185 func (m *UserMutation) Where(ps ...predicate.User) { 6186 m.predicates = append(m.predicates, ps...) 6187 } 6188 6189 // WhereP appends storage-level predicates to the UserMutation builder. Using this method, 6190 // users can use type-assertion to append predicates that do not depend on any generated package. 6191 func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) { 6192 p := make([]predicate.User, len(ps)) 6193 for i := range ps { 6194 p[i] = ps[i] 6195 } 6196 m.Where(p...) 6197 } 6198 6199 // Op returns the operation name. 6200 func (m *UserMutation) Op() Op { 6201 return m.op 6202 } 6203 6204 // SetOp allows setting the mutation operation. 6205 func (m *UserMutation) SetOp(op Op) { 6206 m.op = op 6207 } 6208 6209 // Type returns the node type of this mutation (User). 6210 func (m *UserMutation) Type() string { 6211 return m.typ 6212 } 6213 6214 // Fields returns all fields that were changed during this mutation. Note that in 6215 // order to get all numeric fields that were incremented/decremented, call 6216 // AddedFields(). 6217 func (m *UserMutation) Fields() []string { 6218 fields := make([]string, 0, 6) 6219 if m.username != nil { 6220 fields = append(fields, user.FieldUsername) 6221 } 6222 if m.password != nil { 6223 fields = append(fields, user.FieldPassword) 6224 } 6225 if m.role != nil { 6226 fields = append(fields, user.FieldRole) 6227 } 6228 if m.created_at != nil { 6229 fields = append(fields, user.FieldCreatedAt) 6230 } 6231 if m.updated_at != nil { 6232 fields = append(fields, user.FieldUpdatedAt) 6233 } 6234 if m.deleted_at != nil { 6235 fields = append(fields, user.FieldDeletedAt) 6236 } 6237 return fields 6238 } 6239 6240 // Field returns the value of a field with the given name. The second boolean 6241 // return value indicates that this field was not set, or was not defined in the 6242 // schema. 6243 func (m *UserMutation) Field(name string) (ent.Value, bool) { 6244 switch name { 6245 case user.FieldUsername: 6246 return m.Username() 6247 case user.FieldPassword: 6248 return m.Password() 6249 case user.FieldRole: 6250 return m.Role() 6251 case user.FieldCreatedAt: 6252 return m.CreatedAt() 6253 case user.FieldUpdatedAt: 6254 return m.UpdatedAt() 6255 case user.FieldDeletedAt: 6256 return m.DeletedAt() 6257 } 6258 return nil, false 6259 } 6260 6261 // OldField returns the old value of the field from the database. An error is 6262 // returned if the mutation operation is not UpdateOne, or the query to the 6263 // database failed. 6264 func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 6265 switch name { 6266 case user.FieldUsername: 6267 return m.OldUsername(ctx) 6268 case user.FieldPassword: 6269 return m.OldPassword(ctx) 6270 case user.FieldRole: 6271 return m.OldRole(ctx) 6272 case user.FieldCreatedAt: 6273 return m.OldCreatedAt(ctx) 6274 case user.FieldUpdatedAt: 6275 return m.OldUpdatedAt(ctx) 6276 case user.FieldDeletedAt: 6277 return m.OldDeletedAt(ctx) 6278 } 6279 return nil, fmt.Errorf("unknown User field %s", name) 6280 } 6281 6282 // SetField sets the value of a field with the given name. It returns an error if 6283 // the field is not defined in the schema, or if the type mismatched the field 6284 // type. 6285 func (m *UserMutation) SetField(name string, value ent.Value) error { 6286 switch name { 6287 case user.FieldUsername: 6288 v, ok := value.(string) 6289 if !ok { 6290 return fmt.Errorf("unexpected type %T for field %s", value, name) 6291 } 6292 m.SetUsername(v) 6293 return nil 6294 case user.FieldPassword: 6295 v, ok := value.(string) 6296 if !ok { 6297 return fmt.Errorf("unexpected type %T for field %s", value, name) 6298 } 6299 m.SetPassword(v) 6300 return nil 6301 case user.FieldRole: 6302 v, ok := value.(string) 6303 if !ok { 6304 return fmt.Errorf("unexpected type %T for field %s", value, name) 6305 } 6306 m.SetRole(v) 6307 return nil 6308 case user.FieldCreatedAt: 6309 v, ok := value.(time.Time) 6310 if !ok { 6311 return fmt.Errorf("unexpected type %T for field %s", value, name) 6312 } 6313 m.SetCreatedAt(v) 6314 return nil 6315 case user.FieldUpdatedAt: 6316 v, ok := value.(time.Time) 6317 if !ok { 6318 return fmt.Errorf("unexpected type %T for field %s", value, name) 6319 } 6320 m.SetUpdatedAt(v) 6321 return nil 6322 case user.FieldDeletedAt: 6323 v, ok := value.(time.Time) 6324 if !ok { 6325 return fmt.Errorf("unexpected type %T for field %s", value, name) 6326 } 6327 m.SetDeletedAt(v) 6328 return nil 6329 } 6330 return fmt.Errorf("unknown User field %s", name) 6331 } 6332 6333 // AddedFields returns all numeric fields that were incremented/decremented during 6334 // this mutation. 6335 func (m *UserMutation) AddedFields() []string { 6336 return nil 6337 } 6338 6339 // AddedField returns the numeric value that was incremented/decremented on a field 6340 // with the given name. The second boolean return value indicates that this field 6341 // was not set, or was not defined in the schema. 6342 func (m *UserMutation) AddedField(name string) (ent.Value, bool) { 6343 return nil, false 6344 } 6345 6346 // AddField adds the value to the field with the given name. It returns an error if 6347 // the field is not defined in the schema, or if the type mismatched the field 6348 // type. 6349 func (m *UserMutation) AddField(name string, value ent.Value) error { 6350 switch name { 6351 } 6352 return fmt.Errorf("unknown User numeric field %s", name) 6353 } 6354 6355 // ClearedFields returns all nullable fields that were cleared during this 6356 // mutation. 6357 func (m *UserMutation) ClearedFields() []string { 6358 var fields []string 6359 if m.FieldCleared(user.FieldDeletedAt) { 6360 fields = append(fields, user.FieldDeletedAt) 6361 } 6362 return fields 6363 } 6364 6365 // FieldCleared returns a boolean indicating if a field with the given name was 6366 // cleared in this mutation. 6367 func (m *UserMutation) FieldCleared(name string) bool { 6368 _, ok := m.clearedFields[name] 6369 return ok 6370 } 6371 6372 // ClearField clears the value of the field with the given name. It returns an 6373 // error if the field is not defined in the schema. 6374 func (m *UserMutation) ClearField(name string) error { 6375 switch name { 6376 case user.FieldDeletedAt: 6377 m.ClearDeletedAt() 6378 return nil 6379 } 6380 return fmt.Errorf("unknown User nullable field %s", name) 6381 } 6382 6383 // ResetField resets all changes in the mutation for the field with the given name. 6384 // It returns an error if the field is not defined in the schema. 6385 func (m *UserMutation) ResetField(name string) error { 6386 switch name { 6387 case user.FieldUsername: 6388 m.ResetUsername() 6389 return nil 6390 case user.FieldPassword: 6391 m.ResetPassword() 6392 return nil 6393 case user.FieldRole: 6394 m.ResetRole() 6395 return nil 6396 case user.FieldCreatedAt: 6397 m.ResetCreatedAt() 6398 return nil 6399 case user.FieldUpdatedAt: 6400 m.ResetUpdatedAt() 6401 return nil 6402 case user.FieldDeletedAt: 6403 m.ResetDeletedAt() 6404 return nil 6405 } 6406 return fmt.Errorf("unknown User field %s", name) 6407 } 6408 6409 // AddedEdges returns all edge names that were set/added in this mutation. 6410 func (m *UserMutation) AddedEdges() []string { 6411 edges := make([]string, 0, 5) 6412 if m.tokens != nil { 6413 edges = append(edges, user.EdgeTokens) 6414 } 6415 if m.subscribed_feeds != nil { 6416 edges = append(edges, user.EdgeSubscribedFeeds) 6417 } 6418 if m.read_items != nil { 6419 edges = append(edges, user.EdgeReadItems) 6420 } 6421 if m.subscriptions != nil { 6422 edges = append(edges, user.EdgeSubscriptions) 6423 } 6424 if m.reads != nil { 6425 edges = append(edges, user.EdgeReads) 6426 } 6427 return edges 6428 } 6429 6430 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 6431 // name in this mutation. 6432 func (m *UserMutation) AddedIDs(name string) []ent.Value { 6433 switch name { 6434 case user.EdgeTokens: 6435 ids := make([]ent.Value, 0, len(m.tokens)) 6436 for id := range m.tokens { 6437 ids = append(ids, id) 6438 } 6439 return ids 6440 case user.EdgeSubscribedFeeds: 6441 ids := make([]ent.Value, 0, len(m.subscribed_feeds)) 6442 for id := range m.subscribed_feeds { 6443 ids = append(ids, id) 6444 } 6445 return ids 6446 case user.EdgeReadItems: 6447 ids := make([]ent.Value, 0, len(m.read_items)) 6448 for id := range m.read_items { 6449 ids = append(ids, id) 6450 } 6451 return ids 6452 case user.EdgeSubscriptions: 6453 ids := make([]ent.Value, 0, len(m.subscriptions)) 6454 for id := range m.subscriptions { 6455 ids = append(ids, id) 6456 } 6457 return ids 6458 case user.EdgeReads: 6459 ids := make([]ent.Value, 0, len(m.reads)) 6460 for id := range m.reads { 6461 ids = append(ids, id) 6462 } 6463 return ids 6464 } 6465 return nil 6466 } 6467 6468 // RemovedEdges returns all edge names that were removed in this mutation. 6469 func (m *UserMutation) RemovedEdges() []string { 6470 edges := make([]string, 0, 5) 6471 if m.removedtokens != nil { 6472 edges = append(edges, user.EdgeTokens) 6473 } 6474 if m.removedsubscribed_feeds != nil { 6475 edges = append(edges, user.EdgeSubscribedFeeds) 6476 } 6477 if m.removedread_items != nil { 6478 edges = append(edges, user.EdgeReadItems) 6479 } 6480 if m.removedsubscriptions != nil { 6481 edges = append(edges, user.EdgeSubscriptions) 6482 } 6483 if m.removedreads != nil { 6484 edges = append(edges, user.EdgeReads) 6485 } 6486 return edges 6487 } 6488 6489 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 6490 // the given name in this mutation. 6491 func (m *UserMutation) RemovedIDs(name string) []ent.Value { 6492 switch name { 6493 case user.EdgeTokens: 6494 ids := make([]ent.Value, 0, len(m.removedtokens)) 6495 for id := range m.removedtokens { 6496 ids = append(ids, id) 6497 } 6498 return ids 6499 case user.EdgeSubscribedFeeds: 6500 ids := make([]ent.Value, 0, len(m.removedsubscribed_feeds)) 6501 for id := range m.removedsubscribed_feeds { 6502 ids = append(ids, id) 6503 } 6504 return ids 6505 case user.EdgeReadItems: 6506 ids := make([]ent.Value, 0, len(m.removedread_items)) 6507 for id := range m.removedread_items { 6508 ids = append(ids, id) 6509 } 6510 return ids 6511 case user.EdgeSubscriptions: 6512 ids := make([]ent.Value, 0, len(m.removedsubscriptions)) 6513 for id := range m.removedsubscriptions { 6514 ids = append(ids, id) 6515 } 6516 return ids 6517 case user.EdgeReads: 6518 ids := make([]ent.Value, 0, len(m.removedreads)) 6519 for id := range m.removedreads { 6520 ids = append(ids, id) 6521 } 6522 return ids 6523 } 6524 return nil 6525 } 6526 6527 // ClearedEdges returns all edge names that were cleared in this mutation. 6528 func (m *UserMutation) ClearedEdges() []string { 6529 edges := make([]string, 0, 5) 6530 if m.clearedtokens { 6531 edges = append(edges, user.EdgeTokens) 6532 } 6533 if m.clearedsubscribed_feeds { 6534 edges = append(edges, user.EdgeSubscribedFeeds) 6535 } 6536 if m.clearedread_items { 6537 edges = append(edges, user.EdgeReadItems) 6538 } 6539 if m.clearedsubscriptions { 6540 edges = append(edges, user.EdgeSubscriptions) 6541 } 6542 if m.clearedreads { 6543 edges = append(edges, user.EdgeReads) 6544 } 6545 return edges 6546 } 6547 6548 // EdgeCleared returns a boolean which indicates if the edge with the given name 6549 // was cleared in this mutation. 6550 func (m *UserMutation) EdgeCleared(name string) bool { 6551 switch name { 6552 case user.EdgeTokens: 6553 return m.clearedtokens 6554 case user.EdgeSubscribedFeeds: 6555 return m.clearedsubscribed_feeds 6556 case user.EdgeReadItems: 6557 return m.clearedread_items 6558 case user.EdgeSubscriptions: 6559 return m.clearedsubscriptions 6560 case user.EdgeReads: 6561 return m.clearedreads 6562 } 6563 return false 6564 } 6565 6566 // ClearEdge clears the value of the edge with the given name. It returns an error 6567 // if that edge is not defined in the schema. 6568 func (m *UserMutation) ClearEdge(name string) error { 6569 switch name { 6570 } 6571 return fmt.Errorf("unknown User unique edge %s", name) 6572 } 6573 6574 // ResetEdge resets all changes to the edge with the given name in this mutation. 6575 // It returns an error if the edge is not defined in the schema. 6576 func (m *UserMutation) ResetEdge(name string) error { 6577 switch name { 6578 case user.EdgeTokens: 6579 m.ResetTokens() 6580 return nil 6581 case user.EdgeSubscribedFeeds: 6582 m.ResetSubscribedFeeds() 6583 return nil 6584 case user.EdgeReadItems: 6585 m.ResetReadItems() 6586 return nil 6587 case user.EdgeSubscriptions: 6588 m.ResetSubscriptions() 6589 return nil 6590 case user.EdgeReads: 6591 m.ResetReads() 6592 return nil 6593 } 6594 return fmt.Errorf("unknown User edge %s", name) 6595 }