IDs queries the database and returns the entity ids that match the mutation's predicate. That means, if the mutation is applied within a transaction with an isolation level such as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated or updated by the mutation.
(ctx context.Context)
| 12630 | // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated |
| 12631 | // or updated by the mutation. |
| 12632 | func (m *StoragePolicyMutation) IDs(ctx context.Context) ([]int, error) { |
| 12633 | switch { |
| 12634 | case m.op.Is(OpUpdateOne | OpDeleteOne): |
| 12635 | id, exists := m.ID() |
| 12636 | if exists { |
| 12637 | return []int{id}, nil |
| 12638 | } |
| 12639 | fallthrough |
| 12640 | case m.op.Is(OpUpdate | OpDelete): |
| 12641 | return m.Client().StoragePolicy.Query().Where(m.predicates...).IDs(ctx) |
| 12642 | default: |
| 12643 | return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) |
| 12644 | } |
| 12645 | } |
| 12646 | |
| 12647 | // SetCreatedAt sets the "created_at" field. |
| 12648 | func (m *StoragePolicyMutation) SetCreatedAt(t time.Time) { |