func (vmq *ValidMessageQuery) Only(ctx context.Context) (*ValidMessage, error) {
	nodes, err := vmq.Limit(2).All(ctx)
	if err != nil {
		return nil, err
	}
	switch len(nodes) {
	case 1:
		return nodes[0], nil
	case 0:
		return nil, &NotFoundError{validmessage.Label}
	default:
		return nil, &NotSingularError{validmessage.Label}
	}
}
Only returns a single ValidMessage entity found by the query, ensuring it only returns one.
Returns a *NotSingularError when exactly one ValidMessage entity is not found.
Returns a *NotFoundError when no ValidMessage entities are found.
package ent
import (
	"context"
	"errors"
	"fmt"
	"math"
	"entgo.io/contrib/entproto/internal/entprototest/ent/predicate"
	"entgo.io/contrib/entproto/internal/entprototest/ent/validmessage"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
)
type ValidMessageQuery struct {
	config
	limit      *int
	offset     *int
	unique     *bool
	order      []OrderFunc
	fields     []string
	predicates []predicate.ValidMessage
	sql  *sql.Selector
	path func(context.Context) (*sql.Selector, error)
}
func (vmq *ValidMessageQuery) Where(ps ...predicate.ValidMessage) *ValidMessageQuery {
	vmq.predicates = append(vmq.predicates, ps...)
	return vmq
}
func (vmq *ValidMessageQuery) Limit(limit int) *ValidMessageQuery {
	vmq.limit = &limit
	return vmq
}
func (vmq *ValidMessageQuery) Offset(offset int) *ValidMessageQuery {
	vmq.offset = &offset
	return vmq
}
func (vmq *ValidMessageQuery) Unique(unique bool) *ValidMessageQuery {
	vmq.unique = &unique
	return vmq
}
func (vmq *ValidMessageQuery) Order(o ...OrderFunc) *ValidMessageQuery {
	vmq.order = append(vmq.order, o...)
	return vmq
}
func (vmq *ValidMessageQuery) First(ctx context.Context) (*ValidMessage, error) {
	nodes, err := vmq.Limit(1).All(ctx)
	if err != nil {
		return nil, err
	}
	if len(nodes) == 0 {
		return nil, &NotFoundError{validmessage.Label}
	}
	return nodes[0], nil
}
func (vmq *ValidMessageQuery) FirstX(ctx context.Context) *ValidMessage {
	node, err := vmq.First(ctx)
	if err != nil && !IsNotFound(err) {
		panic(err)
	}
	return node
}
func (vmq *ValidMessageQuery) FirstID(ctx context.Context) (id int, err error) {
	var ids []int
	if ids, err = vmq.Limit(1).IDs(ctx); err != nil {
		return
	}
	if len(ids) == 0 {
		err = &NotFoundError{validmessage.Label}
		return
	}
	return ids[0], nil
}
func (vmq *ValidMessageQuery) FirstIDX(ctx context.Context) int {
	id, err := vmq.FirstID(ctx)
	if err != nil && !IsNotFound(err) {
		panic(err)
	}
	return id
}