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)
| 187 | // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated |
| 188 | // or updated by the mutation. |
| 189 | func (m *APITokenMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { |
| 190 | switch { |
| 191 | case m.op.Is(OpUpdateOne | OpDeleteOne): |
| 192 | id, exists := m.ID() |
| 193 | if exists { |
| 194 | return []uuid.UUID{id}, nil |
| 195 | } |
| 196 | fallthrough |
| 197 | case m.op.Is(OpUpdate | OpDelete): |
| 198 | return m.Client().APIToken.Query().Where(m.predicates...).IDs(ctx) |
| 199 | default: |
| 200 | return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | // SetName sets the "name" field. |
| 205 | func (m *APITokenMutation) SetName(s string) { |