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

Function _serialize

databases/mongo.js:1032–1060  ·  view source on GitHub ↗
(document)

Source from the content-addressed store, hash-verified

1030}
1031
1032function _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}
1061function _deserialize(docs) {
1062 try {
1063 if (docs.length > 0) {

Callers 1

_saveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected