First returns the first DBPackage entity from the query. Returns a *NotFoundError when no DBPackage was found.
(ctx context.Context)
| 62 | // First returns the first DBPackage entity from the query. |
| 63 | // Returns a *NotFoundError when no DBPackage was found. |
| 64 | func (_q *DBPackageQuery) First(ctx context.Context) (*DBPackage, error) { |
| 65 | nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) |
| 66 | if err != nil { |
| 67 | return nil, err |
| 68 | } |
| 69 | if len(nodes) == 0 { |
| 70 | return nil, &NotFoundError{dbpackage.Label} |
| 71 | } |
| 72 | return nodes[0], nil |
| 73 | } |
| 74 | |
| 75 | // FirstX is like First, but panics if an error occurs. |
| 76 | func (_q *DBPackageQuery) FirstX(ctx context.Context) *DBPackage { |
no test coverage detected