mirror of
https://github.com/JonasunderscoreJones/jonas_jones-api.git
synced 2025-10-24 17:49:18 +02:00
some progress
This commit is contained in:
parent
aea93a5527
commit
e3c15bd288
1388 changed files with 306946 additions and 68323 deletions
33
node_modules/mongoose/lib/helpers/projection/parseProjection.js
generated
vendored
Normal file
33
node_modules/mongoose/lib/helpers/projection/parseProjection.js
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* Convert a string or array into a projection object, retaining all
|
||||
* `-` and `+` paths.
|
||||
*/
|
||||
|
||||
module.exports = function parseProjection(v, retainMinusPaths) {
|
||||
const type = typeof v;
|
||||
|
||||
if (type === 'string') {
|
||||
v = v.split(/\s+/);
|
||||
}
|
||||
if (!Array.isArray(v) && Object.prototype.toString.call(v) !== '[object Arguments]') {
|
||||
return v;
|
||||
}
|
||||
|
||||
const len = v.length;
|
||||
const ret = {};
|
||||
for (let i = 0; i < len; ++i) {
|
||||
let field = v[i];
|
||||
if (!field) {
|
||||
continue;
|
||||
}
|
||||
const include = '-' == field[0] ? 0 : 1;
|
||||
if (!retainMinusPaths && include === 0) {
|
||||
field = field.substring(1);
|
||||
}
|
||||
ret[field] = include;
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue