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)
| 3098 | // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated |
| 3099 | // or updated by the mutation. |
| 3100 | func (m *FileMutation) IDs(ctx context.Context) ([]int, error) { |
| 3101 | switch { |
| 3102 | case m.op.Is(OpUpdateOne | OpDeleteOne): |
| 3103 | id, exists := m.ID() |
| 3104 | if exists { |
| 3105 | return []int{id}, nil |
| 3106 | } |
| 3107 | fallthrough |
| 3108 | case m.op.Is(OpUpdate | OpDelete): |
| 3109 | return m.Client().File.Query().Where(m.predicates...).IDs(ctx) |
| 3110 | default: |
| 3111 | return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) |
| 3112 | } |
| 3113 | } |
| 3114 | |
| 3115 | // SetCreatedAt sets the "created_at" field. |
| 3116 | func (m *FileMutation) SetCreatedAt(t time.Time) { |