MCPcopy
hub / github.com/cloudreve/cloudreve / First

Method First

ent/node_query.go:87–96  ·  view source on GitHub ↗

First returns the first Node entity from the query. Returns a *NotFoundError when no Node was found.

(ctx context.Context)

Source from the content-addressed store, hash-verified

85// First returns the first Node entity from the query.
86// Returns a *NotFoundError when no Node was found.
87func (nq *NodeQuery) First(ctx context.Context) (*Node, error) {
88 nodes, err := nq.Limit(1).All(setContextOp(ctx, nq.ctx, "First"))
89 if err != nil {
90 return nil, err
91 }
92 if len(nodes) == 0 {
93 return nil, &NotFoundError{node.Label}
94 }
95 return nodes[0], nil
96}
97
98// FirstX is like First, but panics if an error occurs.
99func (nq *NodeQuery) FirstX(ctx context.Context) *Node {

Callers 15

FirstXMethod · 0.95
migrateShareMethod · 0.45
migrateDirectLinkMethod · 0.45
GetByIDMethod · 0.45
GetByNameIDMethod · 0.45
CreateDirectLinkMethod · 0.45
GetByHashIDMethod · 0.45
GetParentFileMethod · 0.45
GetChildFileMethod · 0.45
RootMethod · 0.45
GetEntityByIDMethod · 0.45
GetByIDMethod · 0.45

Calls 3

LimitMethod · 0.95
setContextOpFunction · 0.85
AllMethod · 0.45

Tested by

no test coverage detected