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