func (bpq *BlogPostQuery) FirstIDX(ctx context.Context) int {
	id, err := bpq.FirstID(ctx)
	if err != nil && !IsNotFound(err) {
		panic(err)
	}
	return id
}
FirstIDX is like FirstID, but panics if an error occurs.
package ent
import (
	"context"
	"database/sql/driver"
	"errors"
	"fmt"
	"math"
	"entgo.io/contrib/entproto/internal/entprototest/ent/blogpost"
	"entgo.io/contrib/entproto/internal/entprototest/ent/category"
	"entgo.io/contrib/entproto/internal/entprototest/ent/predicate"
	"entgo.io/contrib/entproto/internal/entprototest/ent/user"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
)
type BlogPostQuery struct {
	config
	limit      *int
	offset     *int
	unique     *bool
	order      []OrderFunc
	fields     []string
	predicates []predicate.BlogPost
	withAuthor     *UserQuery
	withCategories *CategoryQuery
	withFKs        bool
	sql  *sql.Selector
	path func(context.Context) (*sql.Selector, error)
}
func (bpq *BlogPostQuery) Where(ps ...predicate.BlogPost) *BlogPostQuery {
	bpq.predicates = append(bpq.predicates, ps...)
	return bpq
}
func (bpq *BlogPostQuery) Limit(limit int) *BlogPostQuery {
	bpq.limit = &limit
	return bpq
}
func (bpq *BlogPostQuery) Offset(offset int) *BlogPostQuery {
	bpq.offset = &offset
	return bpq
}
func (bpq *BlogPostQuery) Unique(unique bool) *BlogPostQuery {
	bpq.unique = &unique
	return bpq
}
func (bpq *BlogPostQuery) Order(o ...OrderFunc) *BlogPostQuery {
	bpq.order = append(bpq.order, o...)
	return bpq
}
func (bpq *BlogPostQuery) QueryAuthor() *UserQuery {
	query := &UserQuery{config: bpq.config}
	query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
		if err := bpq.prepareQuery(ctx); err != nil {
			return nil, err
		}
		selector := bpq.sqlQuery(ctx)
		if err := selector.Err(); err != nil {
			return nil, err
		}
		step := sqlgraph.NewStep(
			sqlgraph.From(blogpost.Table, blogpost.FieldID, selector),
			sqlgraph.To(user.Table, user.FieldID),
			sqlgraph.Edge(sqlgraph.M2O, false, blogpost.AuthorTable, blogpost.AuthorColumn),
		)
		fromU = sqlgraph.SetNeighbors(bpq.driver.Dialect(), step)
		return fromU, nil
	}
	return query
}
func (bpq *BlogPostQuery) QueryCategories() *CategoryQuery {
	query := &CategoryQuery{config: bpq.config}
	query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
		if err := bpq.prepareQuery(ctx); err != nil {
			return nil, err
		}
		selector := bpq.sqlQuery(ctx)
		if err := selector.Err(); err != nil {
			return nil, err
		}
		step := sqlgraph.NewStep(
			sqlgraph.From(blogpost.Table, blogpost.FieldID, selector),
			sqlgraph.To(category.Table, category.FieldID),
			sqlgraph.Edge(sqlgraph.M2M, true, blogpost.CategoriesTable, blogpost.CategoriesPrimaryKey...),
		)
		fromU = sqlgraph.SetNeighbors(bpq.driver.Dialect(), step)
		return fromU, nil
	}
	return query
}
func (bpq *BlogPostQuery) First(ctx context.Context) (*BlogPost, error) {
	nodes, err := bpq.Limit(1).All(ctx)
	if err != nil {
		return nil, err
	}
	if len(nodes) == 0 {
		return nil, &NotFoundError{blogpost.Label}
	}
	return nodes[0], nil
}
func (bpq *BlogPostQuery) FirstX(ctx context.Context) *BlogPost {
	node, err := bpq.First(ctx)
	if err != nil && !IsNotFound(err) {
		panic(err)
	}
	return node
}
func (bpq *BlogPostQuery) FirstID(ctx context.Context) (id int, err error) {
	var ids []int
	if ids, err = bpq.Limit(1).IDs(ctx); err != nil {
		return
	}
	if len(ids) == 0 {
		err = &NotFoundError{blogpost.Label}
		return
	}
	return ids[0], nil
}