MCPcopy
hub / github.com/spacecloud-io/space-cloud / matchQuery

Method matchQuery

gateway/modules/auth/match.go:131–155  ·  view source on GitHub ↗
(ctx context.Context, project string, rule *config.Rule, crud model.CrudAuthInterface, args, auth map[string]interface{}, returnWhere model.ReturnWhereStub)

Source from the content-addressed store, hash-verified

129}
130
131func (m *Module) matchQuery(ctx context.Context, project string, rule *config.Rule, crud model.CrudAuthInterface, args, auth map[string]interface{}, returnWhere model.ReturnWhereStub) (*model.PostProcess, error) {
132 // Adjust the find object to load any variables referenced from state
133 find := utils.Adjust(ctx, rule.Find, args).(map[string]interface{})
134
135 // Create a new read request
136 req := &model.ReadRequest{Find: find, Operation: utils.All}
137 req.Cache = rule.Cache
138
139 // Execute the read request
140 attr := map[string]string{"project": project, "db": rule.DB, "col": rule.Col}
141 data, _, err := crud.Read(ctx, rule.DB, rule.Col, req, model.RequestParams{Claims: auth, Resource: "db-read", Op: "access", Attributes: attr})
142 if err != nil {
143 return nil, formatError(ctx, rule, err)
144 }
145
146 if rule.Store == "" {
147 rule.Store = "args.result"
148 }
149 if err := utils.StoreValue(ctx, rule.Store, data, args); err != nil {
150 return nil, formatError(ctx, rule, err)
151 }
152
153 postProcess, err := m.matchRule(ctx, project, rule.Clause, args, auth, returnWhere)
154 return postProcess, formatError(ctx, rule, err)
155}
156
157func (m *Module) matchAnd(ctx context.Context, projectID string, rule *config.Rule, args, auth map[string]interface{}, returnWhere model.ReturnWhereStub) (*model.PostProcess, error) {
158 completeAction := &model.PostProcess{}

Callers 1

matchRuleMethod · 0.95

Calls 3

matchRuleMethod · 0.95
formatErrorFunction · 0.85
ReadMethod · 0.65

Tested by

no test coverage detected