func (bq *BeerQuery) OnlyID(ctx context.Context) (id int64, err error) {
	var ids []int64
	if ids, err = bq.Limit(2).IDs(ctx); err != nil {
		return
	}
	switch len(ids) {
	case 1:
		id = ids[0]
	case 0:
		err = &NotFoundError{beer.Label}
	default:
		err = &NotSingularError{beer.Label}
	}
	return
}
OnlyID is like Only, but returns the only Beer ID in the query.
Returns a *NotSingularError when exactly one Beer ID is not found.
Returns a *NotFoundError when no entities are found.
package ent
import (
	"context"
	"errors"
	"fmt"
	"math"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
	"github.com/go-kratos/beer-shop/app/catalog/service/internal/data/ent/beer"
	"github.com/go-kratos/beer-shop/app/catalog/service/internal/data/ent/predicate"
)
type BeerQuery struct {
	config
	limit      *int
	offset     *int
	order      []OrderFunc
	fields     []string
	predicates []predicate.Beer
	sql  *sql.Selector
	path func(context.Context) (*sql.Selector, error)
}
func (bq *BeerQuery) Where(ps ...predicate.Beer) *BeerQuery {
	bq.predicates = append(bq.predicates, ps...)
	return bq
}
func (bq *BeerQuery) Limit(limit int) *BeerQuery {
	bq.limit = &limit
	return bq
}
func (bq *BeerQuery) Offset(offset int) *BeerQuery {
	bq.offset = &offset
	return bq
}
func (bq *BeerQuery) Order(o ...OrderFunc) *BeerQuery {
	bq.order = append(bq.order, o...)
	return bq
}
func (bq *BeerQuery) First(ctx context.Context) (*Beer, error) {
	nodes, err := bq.Limit(1).All(ctx)
	if err != nil {
		return nil, err
	}
	if len(nodes) == 0 {
		return nil, &NotFoundError{beer.Label}
	}
	return nodes[0], nil
}
func (bq *BeerQuery) FirstX(ctx context.Context) *Beer {
	node, err := bq.First(ctx)
	if err != nil && !IsNotFound(err) {
		panic(err)
	}
	return node
}
func (bq *BeerQuery) FirstID(ctx context.Context) (id int64, err error) {
	var ids []int64
	if ids, err = bq.Limit(1).IDs(ctx); err != nil {
		return
	}
	if len(ids) == 0 {
		err = &NotFoundError{beer.Label}
		return
	}
	return ids[0], nil
}
func (bq *BeerQuery) FirstIDX(ctx context.Context) int64 {
	id, err := bq.FirstID(ctx)
	if err != nil && !IsNotFound(err) {
		panic(err)
	}
	return id
}
func (bq *BeerQuery) Only(ctx context.Context) (*Beer, error) {
	nodes, err := bq.Limit(2).All(ctx)
	if err != nil {
		return nil, err
	}
	switch len(nodes) {
	case 1:
		return nodes[0], nil
	case 0:
		return nil, &NotFoundError{beer.Label}
	default:
		return nil, &NotSingularError{beer.Label}
	}
}
func (bq *BeerQuery) OnlyX(ctx context.Context) *Beer {
	node, err := bq.Only(ctx)
	if err != nil {
		panic(err)
	}
	return node
}