MCPcopy Create free account
hub / github.com/efectn/go-orm-benchmarks / FirstID

Method FirstID

bench/ent/model_query.go:84–94  ·  view source on GitHub ↗

FirstID returns the first Model ID from the query. Returns a *NotFoundError when no Model ID was found.

(ctx context.Context)

Source from the content-addressed store, hash-verified

82// FirstID returns the first Model ID from the query.
83// Returns a *NotFoundError when no Model ID was found.
84func (mq *ModelQuery) FirstID(ctx context.Context) (id int, err error) {
85 var ids []int
86 if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil {
87 return
88 }
89 if len(ids) == 0 {
90 err = &NotFoundError{model.Label}
91 return
92 }
93 return ids[0], nil
94}
95
96// FirstIDX is like FirstID, but panics if an error occurs.
97func (mq *ModelQuery) FirstIDX(ctx context.Context) int {

Callers 2

FirstIDXMethod · 0.95
ExistMethod · 0.95

Calls 3

LimitMethod · 0.95
setContextOpFunction · 0.85
IDsMethod · 0.45

Tested by

no test coverage detected