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)
| 6497 | // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated |
| 6498 | // or updated by the mutation. |
| 6499 | func (m *MetadataMutation) IDs(ctx context.Context) ([]int, error) { |
| 6500 | switch { |
| 6501 | case m.op.Is(OpUpdateOne | OpDeleteOne): |
| 6502 | id, exists := m.ID() |
| 6503 | if exists { |
| 6504 | return []int{id}, nil |
| 6505 | } |
| 6506 | fallthrough |
| 6507 | case m.op.Is(OpUpdate | OpDelete): |
| 6508 | return m.Client().Metadata.Query().Where(m.predicates...).IDs(ctx) |
| 6509 | default: |
| 6510 | return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) |
| 6511 | } |
| 6512 | } |
| 6513 | |
| 6514 | // SetCreatedAt sets the "created_at" field. |
| 6515 | func (m *MetadataMutation) SetCreatedAt(t time.Time) { |