MCPcopy
hub / github.com/pocketbase/pocketbase / Parse

Method Parse

tools/search/provider.go:184–225  ·  view source on GitHub ↗

Parse parses the search query parameter from the provided query string and assigns the found fields to the current search provider. The data from the "sort" and "filter" query parameters are appended to the existing provider's `sort` and `filter` fields (aka. using `AddSort` and `AddFilter`).

(urlQuery string)

Source from the content-addressed store, hash-verified

182// to the existing provider's `sort` and `filter` fields
183// (aka. using `AddSort` and `AddFilter`).
184func (s *Provider) Parse(urlQuery string) error {
185 params, err := url.ParseQuery(urlQuery)
186 if err != nil {
187 return err
188 }
189
190 if raw := params.Get(SkipTotalQueryParam); raw != "" {
191 v, err := strconv.ParseBool(raw)
192 if err != nil {
193 return err
194 }
195 s.SkipTotal(v)
196 }
197
198 if raw := params.Get(PageQueryParam); raw != "" {
199 v, err := strconv.Atoi(raw)
200 if err != nil {
201 return err
202 }
203 s.Page(v)
204 }
205
206 if raw := params.Get(PerPageQueryParam); raw != "" {
207 v, err := strconv.Atoi(raw)
208 if err != nil {
209 return err
210 }
211 s.PerPage(v)
212 }
213
214 if raw := params.Get(SortQueryParam); raw != "" {
215 for _, sortField := range ParseSortFromString(raw) {
216 s.AddSort(sortField)
217 }
218 }
219
220 if raw := params.Get(FilterQueryParam); raw != "" {
221 s.AddFilter(FilterData(raw))
222 }
223
224 return nil
225}
226
227// Exec executes the search provider and fills/scans
228// the provided `items` slice with the found models.

Callers 15

ParseAndExecMethod · 0.95
html2TextFunction · 0.80
ScanMethod · 0.80
TestDateTimeTimeFunction · 0.80
RandomStringByRegexFunction · 0.80
ParseJWTFunction · 0.80
FetchAuthUserMethod · 0.80
ValidateTokenSignatureFunction · 0.80
TestNewMomentFunction · 0.80
BuildExprWithLimitMethod · 0.80
TestProviderParseFunction · 0.80

Calls 8

SkipTotalMethod · 0.95
PageMethod · 0.95
PerPageMethod · 0.95
AddSortMethod · 0.95
AddFilterMethod · 0.95
ParseSortFromStringFunction · 0.85
FilterDataTypeAlias · 0.85
GetMethod · 0.65

Tested by 7

TestDateTimeTimeFunction · 0.64
TestNewMomentFunction · 0.64
TestProviderParseFunction · 0.64
TestRendererRenderFunction · 0.64
TestRecordGetDateTimeFunction · 0.64
TestDeleteOldLogsFunction · 0.64