Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docstore/memdocstore/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@ func (c *collection) RunGetQuery(_ context.Context, q *driver.Query) (driver.Doc

var resultDocs []storedDoc
for _, doc := range c.docs {
if q.Limit > 0 && len(resultDocs) == q.Limit {
break
}
if filtersMatch(q.Filters, doc) {
resultDocs = append(resultDocs, doc)
}
}
if q.OrderByField != "" {
sortDocs(resultDocs, q.OrderByField, q.OrderAscending)
}

if q.Limit > 0 && len(resultDocs) > q.Limit {
resultDocs = resultDocs[:q.Limit]
}

// Include the key field in the field paths if there is one.
var fps [][]string
if len(q.FieldPaths) > 0 && c.keyField != "" {
Expand Down