MCPcopy Create free account
hub / github.com/google/go-cloud / Limit

Method Limit

docstore/query.go:146–158  ·  view source on GitHub ↗

Limit will limit the results to at most n documents. n must be positive. It is an error to specify Limit more than once in a Get query, or at all in a Delete or Update query.

(n int)

Source from the content-addressed store, hash-verified

144// It is an error to specify Limit more than once in a Get query, or
145// at all in a Delete or Update query.
146func (q *Query) Limit(n int) *Query {
147 if q.err != nil {
148 return q
149 }
150 if n <= 0 {
151 return q.invalidf("limit value of %d must be greater than zero", n)
152 }
153 if q.dq.Limit > 0 {
154 return q.invalidf("query can have at most one limit clause")
155 }
156 q.dq.Limit = n
157 return q
158}
159
160// Ascending and Descending are constants for use in the OrderBy method.
161const (

Callers 2

TestInvalidQueryFunction · 0.80
testGetQueryFunction · 0.80

Calls 1

invalidfMethod · 0.95

Tested by 1

TestInvalidQueryFunction · 0.64