MCPcopy Index your code
hub / github.com/parse-community/parse-server / includePath

Function includePath

src/RestQuery.js:1178–1288  ·  view source on GitHub ↗
(config, auth, response, path, context, restOptions = {})

Source from the content-addressed store, hash-verified

1176// Path is a list of field names.
1177// Returns a promise for an augmented response.
1178function includePath(config, auth, response, path, context, restOptions = {}) {
1179 var pointers = findPointers(response.results, path);
1180 if (pointers.length == 0) {
1181 return response;
1182 }
1183 const pointersHash = {};
1184 for (var pointer of pointers) {
1185 if (!pointer) {
1186 continue;
1187 }
1188 const className = pointer.className;
1189 // only include the good pointers
1190 if (className) {
1191 pointersHash[className] = pointersHash[className] || new Set();
1192 pointersHash[className].add(pointer.objectId);
1193 }
1194 }
1195 const includeRestOptions = {};
1196 if (restOptions.keys) {
1197 const keys = new Set(restOptions.keys.split(','));
1198 const keySet = Array.from(keys).reduce((set, key) => {
1199 const keyPath = key.split('.');
1200 let i = 0;
1201 for (i; i < path.length; i++) {
1202 if (path[i] != keyPath[i]) {
1203 return set;
1204 }
1205 }
1206 if (i < keyPath.length) {
1207 set.add(keyPath[i]);
1208 }
1209 return set;
1210 }, new Set());
1211 if (keySet.size > 0) {
1212 includeRestOptions.keys = Array.from(keySet).join(',');
1213 }
1214 }
1215
1216 if (restOptions.excludeKeys) {
1217 const excludeKeys = new Set(restOptions.excludeKeys.split(','));
1218 const excludeKeySet = Array.from(excludeKeys).reduce((set, key) => {
1219 const keyPath = key.split('.');
1220 let i = 0;
1221 for (i; i < path.length; i++) {
1222 if (path[i] != keyPath[i]) {
1223 return set;
1224 }
1225 }
1226 if (i == keyPath.length - 1) {
1227 set.add(keyPath[i]);
1228 }
1229 return set;
1230 }, new Set());
1231 if (excludeKeySet.size > 0) {
1232 includeRestOptions.excludeKeys = Array.from(excludeKeySet).join(',');
1233 }
1234 }
1235

Callers 1

recursiveExecutionTreeFunction · 0.85

Calls 4

findPointersFunction · 0.85
RestQueryFunction · 0.85
replacePointersFunction · 0.85
executeMethod · 0.80

Tested by

no test coverage detected