FirstID returns the first Node ID from the query. Returns a *NotFoundError when no Node ID was found.
(ctx context.Context)
| 158 | // FirstID returns the first Node ID from the query. |
| 159 | // Returns a *NotFoundError when no Node ID was found. |
| 160 | func (nq *NodeQuery) FirstID(ctx context.Context) (id string, err error) { |
| 161 | var ids []string |
| 162 | if ids, err = nq.Limit(1).IDs(setContextOp(ctx, nq.ctx, ent.OpQueryFirstID)); err != nil { |
| 163 | return |
| 164 | } |
| 165 | if len(ids) == 0 { |
| 166 | err = &NotFoundError{node.Label} |
| 167 | return |
| 168 | } |
| 169 | return ids[0], nil |
| 170 | } |
| 171 | |
| 172 | // FirstIDX is like FirstID, but panics if an error occurs. |
| 173 | func (nq *NodeQuery) FirstIDX(ctx context.Context) string { |
no test coverage detected