MCPcopy
hub / github.com/pocketbase/pocketbase / UpdateQuery

Method UpdateQuery

core/record_field_resolver.go:135–158  ·  view source on GitHub ↗

@todo think of a better a way how to call it automatically after BuildExpr UpdateQuery implements `search.FieldResolver` interface. Conditionally updates the provided search query based on the resolved fields (eg. dynamically joining relations).

(query *dbx.SelectQuery)

Source from the content-addressed store, hash-verified

133// Conditionally updates the provided search query based on the
134// resolved fields (eg. dynamically joining relations).
135func (r *RecordFieldResolver) UpdateQuery(query *dbx.SelectQuery) error {
136 if len(r.joins) > 0 {
137 r.updateQueryWithDeduplicateConstraint(query)
138
139 for _, join := range r.joins {
140 query.LeftJoin(
141 (join.TableName + " " + join.TableAlias),
142 join.On,
143 )
144 }
145 }
146
147 // note: for now the joins are not applied for multi-match conditions to avoid excessive checks
148 if len(r.listRuleJoins) > 0 {
149 for _, join := range r.listRuleJoins {
150 err := r.updateQueryWithCollectionListRule(join.collection, join.tableAlias, query)
151 if err != nil {
152 return err
153 }
154 }
155 }
156
157 return nil
158}
159
160func (r *RecordFieldResolver) updateQueryWithCollectionListRule(c *Collection, tableAlias string, query *dbx.SelectQuery) error {
161 if r.allowHiddenFields || c == nil || c.ListRule == nil || *c.ListRule == "" {

Callers 12

FindRecordsByFilterMethod · 0.95
CanAccessRecordMethod · 0.95
wantsMFAFunction · 0.95
expandFetchFunction · 0.95
autoResolveRecordsFlagsFunction · 0.95
recordViewFunction · 0.95
recordCreateFunction · 0.95
recordUpdateFunction · 0.95
recordDeleteFunction · 0.95
hasAuthManageAccessFunction · 0.95
realtimeCanAccessRecordFunction · 0.95

Tested by 1