MCPcopy Create free account
hub / github.com/CloudBoost/cloudboost / _recursiveModifyQuery

Function _recursiveModifyQuery

services/cloudObjects.js:1175–1205  ·  view source on GitHub ↗
(query, columnNames, type, encryptionKey)

Source from the content-addressed store, hash-verified

1173}
1174
1175function _recursiveModifyQuery(query, columnNames, type, encryptionKey) {
1176 for (var key in query) {
1177 if (key === '$or') {
1178 for (var i = 0; i < query[key].length; i++) {
1179 query[key][i] = _recursiveModifyQuery(query[key][i], columnNames, type, encryptionKey);
1180 }
1181 }
1182 }
1183 return _.mapObject(query, function(val, key) {
1184 if (columnNames.indexOf(key) > -1) {
1185 if (typeof val !== 'object') {
1186 if (type === 'encrypt') {
1187 return _encrypt(val, encryptionKey);
1188 }
1189 } else {
1190 // for datetime fields convert them to a fomat which mongodb can query
1191 if (type === 'datetime') {
1192 try {
1193 Object.keys(val).map(function(x) {
1194 val[x] = new Date(val[x]);
1195 });
1196 return val;
1197 } catch (e) {
1198 return val;
1199 }
1200 }
1201 }
1202 }
1203 return val;
1204 });
1205}
1206
1207function _attachSchema(docsArray, oldDocs) {
1208 try {

Callers 1

_modifyFieldsInQueryFunction · 0.85

Calls 1

_encryptFunction · 0.85

Tested by

no test coverage detected