// Only returns a single APIAudit entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when exactly one APIAudit entity is not found.
// Returns a *NotFoundError when no APIAudit entities are found.
Only returns a single APIAudit entity found by the query, ensuring it only returns one.
Returns a *NotSingularError when exactly one APIAudit entity is not found.
Returns a *NotFoundError when no APIAudit entities are found.
// Only returns a single APIAudit entity found by the query ensuring it only returns one . // Returns a * NotSingularError when exactly one APIAudit entity is not found . // Returns a * NotFoundError when no APIAudit entities are found .
func (aaq *APIAuditQuery) Only(ctx context.Context) (*APIAudit, error) {
	nodes, err := aaq.Limit(2).All(ctx)
	if err != nil {
		return nil, err
	}
	switch len(nodes) {
	case 1:
		return nodes[0], nil
	case 0:
		return nil, &NotFoundError{apiaudit.Label}
	default:
		return nil, &NotSingularError{apiaudit.Label}
	}
}
func ( aaq * APIAuditQuery ) Only ( ctx context . Context ) ( * APIAudit , error ) { nodes , err := aaq . Limit ( 2 ) . All ( ctx ) if err != nil { return nil , err } switch len ( nodes ) { case 1 : return nodes [ 0 ] , nil case 0 : return nil , & NotFoundError { apiaudit . Label } default : return nil , & NotSingularError { apiaudit . Label } } }
Only returns a single APIAudit entity found by the query, ensuring it only returns one.
Only returns a single APIAudit entity found by the query ensuring it only returns one .