sanitizes json before it comes out of global and collection find operations

This commit is contained in:
James
2020-10-12 15:13:37 -04:00
parent dea21a0aae
commit fd9453889e
2 changed files with 5 additions and 1 deletions

View File

@@ -87,7 +87,8 @@ async function find(args) {
result = {
...result,
docs: await Promise.all(result.docs.map(async (doc) => {
let docRef = doc;
let docRef = JSON.stringify(doc);
docRef = JSON.parse(docRef);
if (docRef._id) delete docRef._id;
if (typeof docRef.__v !== 'undefined') delete docRef.__v;

View File

@@ -65,6 +65,9 @@ async function findOne(args) {
// 6. Return results
// /////////////////////////////////////
doc = JSON.stringify(doc);
doc = JSON.parse(doc);
return doc;
}