First returns the first StoragePolicy entity from the query. Returns a *NotFoundError when no StoragePolicy was found.
(ctx context.Context)
| 157 | // First returns the first StoragePolicy entity from the query. |
| 158 | // Returns a *NotFoundError when no StoragePolicy was found. |
| 159 | func (spq *StoragePolicyQuery) First(ctx context.Context) (*StoragePolicy, error) { |
| 160 | nodes, err := spq.Limit(1).All(setContextOp(ctx, spq.ctx, "First")) |
| 161 | if err != nil { |
| 162 | return nil, err |
| 163 | } |
| 164 | if len(nodes) == 0 { |
| 165 | return nil, &NotFoundError{storagepolicy.Label} |
| 166 | } |
| 167 | return nodes[0], nil |
| 168 | } |
| 169 | |
| 170 | // FirstX is like First, but panics if an error occurs. |
| 171 | func (spq *StoragePolicyQuery) FirstX(ctx context.Context) *StoragePolicy { |
no test coverage detected