| 1030 | } |
| 1031 | |
| 1032 | function _serialize(document) { |
| 1033 | try { |
| 1034 | Object.keys(document).forEach((key) => { |
| 1035 | if (document[key]) { |
| 1036 | if (document[key].constructor === Object && document[key]._type) { |
| 1037 | if (document[key]._type === 'point') { |
| 1038 | const _obj = {}; |
| 1039 | _obj.type = 'Point'; |
| 1040 | _obj.coordinates = document[key].coordinates; |
| 1041 | document[key] = _obj; |
| 1042 | } |
| 1043 | } |
| 1044 | |
| 1045 | if (key === 'createdAt' || key === 'updatedAt' || key === 'expires') { |
| 1046 | if (typeof document[key] === 'string') { |
| 1047 | document[key] = new Date(document[key]); |
| 1048 | } |
| 1049 | } |
| 1050 | } |
| 1051 | }); |
| 1052 | return document; |
| 1053 | } catch (err) { |
| 1054 | winston.log('error', { |
| 1055 | error: String(err), |
| 1056 | stack: new Error().stack, |
| 1057 | }); |
| 1058 | throw err; |
| 1059 | } |
| 1060 | } |
| 1061 | function _deserialize(docs) { |
| 1062 | try { |
| 1063 | if (docs.length > 0) { |