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)
| 1877 | // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated |
| 1878 | // or updated by the mutation. |
| 1879 | func (m *CASBackendMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { |
| 1880 | switch { |
| 1881 | case m.op.Is(OpUpdateOne | OpDeleteOne): |
| 1882 | id, exists := m.ID() |
| 1883 | if exists { |
| 1884 | return []uuid.UUID{id}, nil |
| 1885 | } |
| 1886 | fallthrough |
| 1887 | case m.op.Is(OpUpdate | OpDelete): |
| 1888 | return m.Client().CASBackend.Query().Where(m.predicates...).IDs(ctx) |
| 1889 | default: |
| 1890 | return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) |
| 1891 | } |
| 1892 | } |
| 1893 | |
| 1894 | // SetLocation sets the "location" field. |
| 1895 | func (m *CASBackendMutation) SetLocation(s string) { |