Exist returns true if the query has elements in the graph.
(ctx context.Context)
| 242 | |
| 243 | // Exist returns true if the query has elements in the graph. |
| 244 | func (nq *NodeQuery) Exist(ctx context.Context) (bool, error) { |
| 245 | ctx = setContextOp(ctx, nq.ctx, "Exist") |
| 246 | switch _, err := nq.FirstID(ctx); { |
| 247 | case IsNotFound(err): |
| 248 | return false, nil |
| 249 | case err != nil: |
| 250 | return false, fmt.Errorf("ent: check existence: %w", err) |
| 251 | default: |
| 252 | return true, nil |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | // ExistX is like Exist, but panics if an error occurs. |
| 257 | func (nq *NodeQuery) ExistX(ctx context.Context) bool { |
no test coverage detected