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)
| 8461 | // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated |
| 8462 | // or updated by the mutation. |
| 8463 | func (m *LockMutation) IDs(ctx context.Context) ([]int, error) { |
| 8464 | switch { |
| 8465 | case m.op.Is(OpUpdateOne | OpDeleteOne): |
| 8466 | id, exists := m.ID() |
| 8467 | if exists { |
| 8468 | return []int{id}, nil |
| 8469 | } |
| 8470 | fallthrough |
| 8471 | case m.op.Is(OpUpdate | OpDelete): |
| 8472 | return m.Client().Lock.Query().Where(m.predicates...).IDs(ctx) |
| 8473 | default: |
| 8474 | return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) |
| 8475 | } |
| 8476 | } |
| 8477 | |
| 8478 | // SetName sets the "name" field. |
| 8479 | func (m *LockMutation) SetName(s string) { |