mirror of
https://github.com/arnaucube/thoughts.git
synced 2026-02-08 12:16:48 +01:00
database externa
This commit is contained in:
36
node_modules/mongoose/lib/schema/operators/bitwise.js
generated
vendored
Normal file
36
node_modules/mongoose/lib/schema/operators/bitwise.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
/*!
|
||||
* Module requirements.
|
||||
*/
|
||||
|
||||
var CastError = require('../../error/cast');
|
||||
|
||||
/*!
|
||||
* ignore
|
||||
*/
|
||||
|
||||
function handleBitwiseOperator(val) {
|
||||
var _this = this;
|
||||
if (Array.isArray(val)) {
|
||||
return val.map(function(v) {
|
||||
return _castNumber(_this.path, v);
|
||||
});
|
||||
} else if (Buffer.isBuffer(val)) {
|
||||
return val;
|
||||
}
|
||||
// Assume trying to cast to number
|
||||
return _castNumber(_this.path, val);
|
||||
}
|
||||
|
||||
/*!
|
||||
* ignore
|
||||
*/
|
||||
|
||||
function _castNumber(path, num) {
|
||||
var v = Number(num);
|
||||
if (isNaN(v)) {
|
||||
throw new CastError('number', num, path);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
module.exports = handleBitwiseOperator;
|
||||
100
node_modules/mongoose/lib/schema/operators/geospatial.js
generated
vendored
Normal file
100
node_modules/mongoose/lib/schema/operators/geospatial.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
/*!
|
||||
* Module requirements.
|
||||
*/
|
||||
|
||||
var castArraysOfNumbers = require('./helpers').castArraysOfNumbers;
|
||||
var castToNumber = require('./helpers').castToNumber;
|
||||
|
||||
/*!
|
||||
* ignore
|
||||
*/
|
||||
|
||||
exports.cast$geoIntersects = cast$geoIntersects;
|
||||
exports.cast$near = cast$near;
|
||||
exports.cast$within = cast$within;
|
||||
|
||||
function cast$near(val) {
|
||||
var SchemaArray = require('../array');
|
||||
|
||||
if (Array.isArray(val)) {
|
||||
castArraysOfNumbers(val, this);
|
||||
return val;
|
||||
}
|
||||
|
||||
_castMinMaxDistance(this, val);
|
||||
|
||||
if (val && val.$geometry) {
|
||||
return cast$geometry(val, this);
|
||||
}
|
||||
|
||||
return SchemaArray.prototype.castForQuery.call(this, val);
|
||||
}
|
||||
|
||||
function cast$geometry(val, self) {
|
||||
switch (val.$geometry.type) {
|
||||
case 'Polygon':
|
||||
case 'LineString':
|
||||
case 'Point':
|
||||
castArraysOfNumbers(val.$geometry.coordinates, self);
|
||||
break;
|
||||
default:
|
||||
// ignore unknowns
|
||||
break;
|
||||
}
|
||||
|
||||
_castMinMaxDistance(this, val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
function cast$within(val) {
|
||||
_castMinMaxDistance(this, val);
|
||||
|
||||
if (val.$box || val.$polygon) {
|
||||
var type = val.$box ? '$box' : '$polygon';
|
||||
val[type].forEach(function(arr) {
|
||||
if (!Array.isArray(arr)) {
|
||||
var msg = 'Invalid $within $box argument. '
|
||||
+ 'Expected an array, received ' + arr;
|
||||
throw new TypeError(msg);
|
||||
}
|
||||
arr.forEach(function(v, i) {
|
||||
arr[i] = castToNumber.call(this, v);
|
||||
});
|
||||
});
|
||||
} else if (val.$center || val.$centerSphere) {
|
||||
type = val.$center ? '$center' : '$centerSphere';
|
||||
val[type].forEach(function(item, i) {
|
||||
if (Array.isArray(item)) {
|
||||
item.forEach(function(v, j) {
|
||||
item[j] = castToNumber.call(this, v);
|
||||
});
|
||||
} else {
|
||||
val[type][i] = castToNumber.call(this, item);
|
||||
}
|
||||
});
|
||||
} else if (val.$geometry) {
|
||||
cast$geometry(val, this);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
function cast$geoIntersects(val) {
|
||||
var geo = val.$geometry;
|
||||
if (!geo) {
|
||||
return;
|
||||
}
|
||||
|
||||
cast$geometry(val, this);
|
||||
return val;
|
||||
}
|
||||
|
||||
function _castMinMaxDistance(self, val) {
|
||||
if (val.$maxDistance) {
|
||||
val.$maxDistance = castToNumber.call(self, val.$maxDistance);
|
||||
}
|
||||
if (val.$minDistance) {
|
||||
val.$minDistance = castToNumber.call(self, val.$minDistance);
|
||||
}
|
||||
}
|
||||
34
node_modules/mongoose/lib/schema/operators/helpers.js
generated
vendored
Normal file
34
node_modules/mongoose/lib/schema/operators/helpers.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
/*!
|
||||
* Module requirements.
|
||||
*/
|
||||
|
||||
var Types = {
|
||||
Number: require('../number')
|
||||
};
|
||||
|
||||
/*!
|
||||
* @ignore
|
||||
*/
|
||||
|
||||
exports.castToNumber = castToNumber;
|
||||
exports.castArraysOfNumbers = castArraysOfNumbers;
|
||||
|
||||
/*!
|
||||
* @ignore
|
||||
*/
|
||||
|
||||
function castToNumber(val) {
|
||||
return Types.Number.prototype.cast.call(this, val);
|
||||
}
|
||||
|
||||
function castArraysOfNumbers(arr, self) {
|
||||
arr.forEach(function(v, i) {
|
||||
if (Array.isArray(v)) {
|
||||
castArraysOfNumbers(v, self);
|
||||
} else {
|
||||
arr[i] = castToNumber.call(self, v);
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user