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

Function _deserialize

databases/mongo.js:1061–1140  ·  view source on GitHub ↗
(docs)

Source from the content-addressed store, hash-verified

1059 }
1060}
1061function _deserialize(docs) {
1062 try {
1063 if (docs.length > 0) {
1064 for (let i = 0; i < docs.length; i++) {
1065 const document = docs[i];
1066 const docKeys = Object.keys(document);
1067 for (let j = 0; j < docKeys.length; j++) {
1068 const key = docKeys[j];
1069 if (document[key]) {
1070 if (document[key].constructor === Object && document[key].type) {
1071 if (document[key].type === 'Point') {
1072 const _obj = {};
1073 _obj._type = 'point';
1074 _obj.coordinates = document[key].coordinates;
1075 _obj.latitude = _obj.coordinates[1]; // eslint-disable-line
1076 _obj.longitude = _obj.coordinates[0]; // eslint-disable-line
1077 document[key] = _obj;
1078 }
1079 } else if (document[key].constructor === Array
1080 && document[key][0]
1081 && document[key][0].type
1082 && document[key][0].type === 'Point') {
1083 const arr = [];
1084 for (let k = 0; k < document[key].length; k++) {
1085 const _obk = {};
1086 _obk._type = 'point';
1087 _obk.coordinates = document[key][k].coordinates;
1088 _obk.latitude = _obk.coordinates[1]; // eslint-disable-line
1089 _obk.longitude = _obk.coordinates[0]; // eslint-disable-line
1090 arr.push(_obk);
1091 }
1092 document[key] = arr;
1093 }
1094 }
1095 }
1096 docs[i] = document;
1097 }
1098 } else {
1099 const document = docs;
1100 const docKeys = Object.keys(document);
1101 for (let k = 0; k < docKeys.length; k++) {
1102 const key = docKeys[k];
1103 if (document[key]) {
1104 if (document[key].constructor === Object && document[key].type) {
1105 if (document[key].type === 'Point') {
1106 const _obj = {};
1107 _obj._type = 'point';
1108 _obj.coordinates = document[key].coordinates;
1109 _obj.latitude = _obj.coordinates[1]; // eslint-disable-line
1110 _obj.longitude = _obj.coordinates[0]; // eslint-disable-line
1111 document[key] = _obj;
1112 }
1113 } else if (document[key].constructor === Array
1114 && document[key][0]
1115 && document[key][0].type
1116 && document[key][0].type === 'Point') {
1117 const arr = [];
1118 for (let j = 0; j < document[key].length; j++) {

Callers 4

_includeFunction · 0.85
findFunction · 0.85
distinctFunction · 0.85
_saveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected