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)
| 15185 | // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated |
| 15186 | // or updated by the mutation. |
| 15187 | func (m *UserMutation) IDs(ctx context.Context) ([]int, error) { |
| 15188 | switch { |
| 15189 | case m.op.Is(OpUpdateOne | OpDeleteOne): |
| 15190 | id, exists := m.ID() |
| 15191 | if exists { |
| 15192 | return []int{id}, nil |
| 15193 | } |
| 15194 | fallthrough |
| 15195 | case m.op.Is(OpUpdate | OpDelete): |
| 15196 | return m.Client().User.Query().Where(m.predicates...).IDs(ctx) |
| 15197 | default: |
| 15198 | return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) |
| 15199 | } |
| 15200 | } |
| 15201 | |
| 15202 | // SetCreatedAt sets the "created_at" field. |
| 15203 | func (m *UserMutation) SetCreatedAt(t time.Time) { |