mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-13 03:02:49 +00:00
updated bunch of file paths and changed the way posts are loaded
This commit is contained in:
52
node_modules/mongoose/lib/cast.js
generated
vendored
52
node_modules/mongoose/lib/cast.js
generated
vendored
@@ -14,14 +14,14 @@ var Types = require('./schema/index');
|
||||
*/
|
||||
|
||||
var cast = module.exports = function(schema, obj) {
|
||||
var paths = Object.keys(obj)
|
||||
, i = paths.length
|
||||
, any$conditionals
|
||||
, schematype
|
||||
, nested
|
||||
, path
|
||||
, type
|
||||
, val;
|
||||
var paths = Object.keys(obj),
|
||||
i = paths.length,
|
||||
any$conditionals,
|
||||
schematype,
|
||||
nested,
|
||||
path,
|
||||
type,
|
||||
val;
|
||||
|
||||
while (i--) {
|
||||
path = paths[i];
|
||||
@@ -29,7 +29,6 @@ var cast = module.exports = function(schema, obj) {
|
||||
|
||||
if ('$or' === path || '$nor' === path || '$and' === path) {
|
||||
var k = val.length;
|
||||
var orComponentQuery;
|
||||
|
||||
while (k--) {
|
||||
val[k] = cast(schema, val[k]);
|
||||
@@ -48,6 +47,10 @@ var cast = module.exports = function(schema, obj) {
|
||||
|
||||
continue;
|
||||
|
||||
} else if (path === '$elemMatch') {
|
||||
|
||||
val = cast(schema, val);
|
||||
|
||||
} else {
|
||||
|
||||
if (!schema) {
|
||||
@@ -59,12 +62,11 @@ var cast = module.exports = function(schema, obj) {
|
||||
|
||||
if (!schematype) {
|
||||
// Handle potential embedded array queries
|
||||
var split = path.split('.')
|
||||
, j = split.length
|
||||
, pathFirstHalf
|
||||
, pathLastHalf
|
||||
, remainingConds
|
||||
, castingQuery;
|
||||
var split = path.split('.'),
|
||||
j = split.length,
|
||||
pathFirstHalf,
|
||||
pathLastHalf,
|
||||
remainingConds;
|
||||
|
||||
// Find the part of the var path that is a path of the Schema
|
||||
while (j--) {
|
||||
@@ -100,7 +102,7 @@ var cast = module.exports = function(schema, obj) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var numbertype = new Types.Number('__QueryCasting__')
|
||||
var numbertype = new Types.Number('__QueryCasting__');
|
||||
var value = val[geo];
|
||||
|
||||
if (val.$maxDistance) {
|
||||
@@ -131,16 +133,16 @@ var cast = module.exports = function(schema, obj) {
|
||||
value = value.$geometry.coordinates;
|
||||
}
|
||||
|
||||
;(function _cast (val) {
|
||||
(function _cast(val) {
|
||||
if (Array.isArray(val)) {
|
||||
val.forEach(function (item, i) {
|
||||
val.forEach(function(item, i) {
|
||||
if (Array.isArray(item) || utils.isObject(item)) {
|
||||
return _cast(item);
|
||||
}
|
||||
val[i] = numbertype.castForQuery(item);
|
||||
});
|
||||
} else {
|
||||
var nearKeys= Object.keys(val);
|
||||
var nearKeys = Object.keys(val);
|
||||
var nearLen = nearKeys.length;
|
||||
while (nearLen--) {
|
||||
var nkey = nearKeys[nearLen];
|
||||
@@ -157,10 +159,11 @@ var cast = module.exports = function(schema, obj) {
|
||||
}
|
||||
|
||||
} else if (val === null || val === undefined) {
|
||||
obj[path] = null;
|
||||
continue;
|
||||
} else if ('Object' === val.constructor.name) {
|
||||
|
||||
any$conditionals = Object.keys(val).some(function (k) {
|
||||
any$conditionals = Object.keys(val).some(function(k) {
|
||||
return k.charAt(0) === '$' && k !== '$id' && k !== '$ref';
|
||||
});
|
||||
|
||||
@@ -168,9 +171,10 @@ var cast = module.exports = function(schema, obj) {
|
||||
obj[path] = schematype.castForQuery(val);
|
||||
} else {
|
||||
|
||||
var ks = Object.keys(val)
|
||||
, k = ks.length
|
||||
, $cond;
|
||||
var ks = Object.keys(val),
|
||||
$cond;
|
||||
|
||||
k = ks.length;
|
||||
|
||||
while (k--) {
|
||||
$cond = ks[k];
|
||||
@@ -204,4 +208,4 @@ var cast = module.exports = function(schema, obj) {
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user