mirror of
https://github.com/JonasunderscoreJones/jonas_jones-api.git
synced 2025-10-24 01:29:19 +02:00
some progress
This commit is contained in:
parent
aea93a5527
commit
e3c15bd288
1388 changed files with 306946 additions and 68323 deletions
35
node_modules/mongoose/lib/helpers/document/handleSpreadDoc.js
generated
vendored
Normal file
35
node_modules/mongoose/lib/helpers/document/handleSpreadDoc.js
generated
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
'use strict';
|
||||
|
||||
const utils = require('../../utils');
|
||||
|
||||
const keysToSkip = new Set(['__index', '__parentArray', '_doc']);
|
||||
|
||||
/**
|
||||
* Using spread operator on a Mongoose document gives you a
|
||||
* POJO that has a tendency to cause infinite recursion. So
|
||||
* we use this function on `set()` to prevent that.
|
||||
*/
|
||||
|
||||
module.exports = function handleSpreadDoc(v, includeExtraKeys) {
|
||||
if (utils.isPOJO(v) && v.$__ != null && v._doc != null) {
|
||||
if (includeExtraKeys) {
|
||||
const extraKeys = {};
|
||||
for (const key of Object.keys(v)) {
|
||||
if (typeof key === 'symbol') {
|
||||
continue;
|
||||
}
|
||||
if (key[0] === '$') {
|
||||
continue;
|
||||
}
|
||||
if (keysToSkip.has(key)) {
|
||||
continue;
|
||||
}
|
||||
extraKeys[key] = v[key];
|
||||
}
|
||||
return { ...v._doc, ...extraKeys };
|
||||
}
|
||||
return v._doc;
|
||||
}
|
||||
|
||||
return v;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue