Exist returns true if the query has elements in the graph.
(ctx context.Context)
| 290 | |
| 291 | // Exist returns true if the query has elements in the graph. |
| 292 | func (eq *EntityQuery) Exist(ctx context.Context) (bool, error) { |
| 293 | ctx = setContextOp(ctx, eq.ctx, "Exist") |
| 294 | switch _, err := eq.FirstID(ctx); { |
| 295 | case IsNotFound(err): |
| 296 | return false, nil |
| 297 | case err != nil: |
| 298 | return false, fmt.Errorf("ent: check existence: %w", err) |
| 299 | default: |
| 300 | return true, nil |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | // ExistX is like Exist, but panics if an error occurs. |
| 305 | func (eq *EntityQuery) ExistX(ctx context.Context) bool { |
no test coverage detected