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
45
node_modules/mquery/lib/collection/collection.js
generated
vendored
Normal file
45
node_modules/mquery/lib/collection/collection.js
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* methods a collection must implement
|
||||
*/
|
||||
|
||||
const methods = [
|
||||
'find',
|
||||
'findOne',
|
||||
'updateMany',
|
||||
'updateOne',
|
||||
'replaceOne',
|
||||
'count',
|
||||
'distinct',
|
||||
'findOneAndDelete',
|
||||
'findOneAndUpdate',
|
||||
'aggregate',
|
||||
'findCursor',
|
||||
'deleteOne',
|
||||
'deleteMany'
|
||||
];
|
||||
|
||||
/**
|
||||
* Collection base class from which implementations inherit
|
||||
*/
|
||||
|
||||
function Collection() {}
|
||||
|
||||
for (let i = 0, len = methods.length; i < len; ++i) {
|
||||
const method = methods[i];
|
||||
Collection.prototype[method] = notImplemented(method);
|
||||
}
|
||||
|
||||
module.exports = exports = Collection;
|
||||
Collection.methods = methods;
|
||||
|
||||
/**
|
||||
* creates a function which throws an implementation error
|
||||
*/
|
||||
|
||||
function notImplemented(method) {
|
||||
return function() {
|
||||
throw new Error('collection.' + method + ' not implemented');
|
||||
};
|
||||
}
|
||||
13
node_modules/mquery/lib/collection/index.js
generated
vendored
Normal file
13
node_modules/mquery/lib/collection/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
const env = require('../env');
|
||||
|
||||
if ('unknown' == env.type) {
|
||||
throw new Error('Unknown environment');
|
||||
}
|
||||
|
||||
module.exports =
|
||||
env.isNode ? require('./node') :
|
||||
env.isMongo ? require('./collection') :
|
||||
require('./collection');
|
||||
|
||||
114
node_modules/mquery/lib/collection/node.js
generated
vendored
Normal file
114
node_modules/mquery/lib/collection/node.js
generated
vendored
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
const Collection = require('./collection');
|
||||
|
||||
class NodeCollection extends Collection {
|
||||
constructor(col) {
|
||||
super();
|
||||
|
||||
this.collection = col;
|
||||
this.collectionName = col.collectionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* find(match, options)
|
||||
*/
|
||||
async find(match, options) {
|
||||
const cursor = this.collection.find(match, options);
|
||||
|
||||
return cursor.toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* findOne(match, options)
|
||||
*/
|
||||
async findOne(match, options) {
|
||||
return this.collection.findOne(match, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* count(match, options)
|
||||
*/
|
||||
async count(match, options) {
|
||||
return this.collection.count(match, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* distinct(prop, match, options)
|
||||
*/
|
||||
async distinct(prop, match, options) {
|
||||
return this.collection.distinct(prop, match, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* updateMany(match, update, options)
|
||||
*/
|
||||
async updateMany(match, update, options) {
|
||||
return this.collection.updateMany(match, update, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* updateOne(match, update, options)
|
||||
*/
|
||||
async updateOne(match, update, options) {
|
||||
return this.collection.updateOne(match, update, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* replaceOne(match, update, options)
|
||||
*/
|
||||
async replaceOne(match, update, options) {
|
||||
return this.collection.replaceOne(match, update, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* deleteOne(match, options)
|
||||
*/
|
||||
async deleteOne(match, options) {
|
||||
return this.collection.deleteOne(match, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* deleteMany(match, options)
|
||||
*/
|
||||
async deleteMany(match, options) {
|
||||
return this.collection.deleteMany(match, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* findOneAndDelete(match, options, function(err[, result])
|
||||
*/
|
||||
async findOneAndDelete(match, options) {
|
||||
return this.collection.findOneAndDelete(match, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* findOneAndUpdate(match, update, options)
|
||||
*/
|
||||
async findOneAndUpdate(match, update, options) {
|
||||
return this.collection.findOneAndUpdate(match, update, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* var cursor = findCursor(match, options)
|
||||
*/
|
||||
findCursor(match, options) {
|
||||
return this.collection.find(match, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* aggregation(operators...)
|
||||
* TODO
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Expose
|
||||
*/
|
||||
|
||||
module.exports = exports = NodeCollection;
|
||||
22
node_modules/mquery/lib/env.js
generated
vendored
Normal file
22
node_modules/mquery/lib/env.js
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
'use strict';
|
||||
|
||||
exports.isNode = 'undefined' != typeof process
|
||||
&& 'object' == typeof module
|
||||
&& 'object' == typeof global
|
||||
&& 'function' == typeof Buffer
|
||||
&& process.argv;
|
||||
|
||||
exports.isMongo = !exports.isNode
|
||||
&& 'function' == typeof printjson
|
||||
&& 'function' == typeof ObjectId
|
||||
&& 'function' == typeof rs
|
||||
&& 'function' == typeof sh;
|
||||
|
||||
exports.isBrowser = !exports.isNode
|
||||
&& !exports.isMongo
|
||||
&& 'undefined' != typeof window;
|
||||
|
||||
exports.type = exports.isNode ? 'node'
|
||||
: exports.isMongo ? 'mongo'
|
||||
: exports.isBrowser ? 'browser'
|
||||
: 'unknown';
|
||||
2705
node_modules/mquery/lib/mquery.js
generated
vendored
Normal file
2705
node_modules/mquery/lib/mquery.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
78
node_modules/mquery/lib/permissions.js
generated
vendored
Normal file
78
node_modules/mquery/lib/permissions.js
generated
vendored
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
'use strict';
|
||||
|
||||
const denied = exports;
|
||||
|
||||
denied.distinct = function(self) {
|
||||
if (self._fields && Object.keys(self._fields).length > 0) {
|
||||
return 'field selection and slice';
|
||||
}
|
||||
|
||||
const keys = Object.keys(denied.distinct);
|
||||
let err;
|
||||
|
||||
keys.every(function(option) {
|
||||
if (self.options[option]) {
|
||||
err = option;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
return err;
|
||||
};
|
||||
denied.distinct.select =
|
||||
denied.distinct.slice =
|
||||
denied.distinct.sort =
|
||||
denied.distinct.limit =
|
||||
denied.distinct.skip =
|
||||
denied.distinct.batchSize =
|
||||
denied.distinct.hint =
|
||||
denied.distinct.tailable = true;
|
||||
|
||||
|
||||
// aggregation integration
|
||||
|
||||
|
||||
denied.findOneAndUpdate =
|
||||
denied.findOneAndRemove = function(self) {
|
||||
const keys = Object.keys(denied.findOneAndUpdate);
|
||||
let err;
|
||||
|
||||
keys.every(function(option) {
|
||||
if (self.options[option]) {
|
||||
err = option;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
return err;
|
||||
};
|
||||
denied.findOneAndUpdate.limit =
|
||||
denied.findOneAndUpdate.skip =
|
||||
denied.findOneAndUpdate.batchSize =
|
||||
denied.findOneAndUpdate.tailable = true;
|
||||
|
||||
|
||||
denied.count = function(self) {
|
||||
if (self._fields && Object.keys(self._fields).length > 0) {
|
||||
return 'field selection and slice';
|
||||
}
|
||||
|
||||
const keys = Object.keys(denied.count);
|
||||
let err;
|
||||
|
||||
keys.every(function(option) {
|
||||
if (self.options[option]) {
|
||||
err = option;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
return err;
|
||||
};
|
||||
|
||||
denied.count.slice =
|
||||
denied.count.batchSize =
|
||||
denied.count.tailable = true;
|
||||
297
node_modules/mquery/lib/utils.js
generated
vendored
Normal file
297
node_modules/mquery/lib/utils.js
generated
vendored
Normal file
|
|
@ -0,0 +1,297 @@
|
|||
'use strict';
|
||||
|
||||
/*!
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
const specialProperties = ['__proto__', 'constructor', 'prototype'];
|
||||
|
||||
/**
|
||||
* Clones objects
|
||||
*
|
||||
* @param {Object} obj the object to clone
|
||||
* @param {Object} options
|
||||
* @return {Object} the cloned object
|
||||
* @api private
|
||||
*/
|
||||
|
||||
const clone = exports.clone = function clone(obj, options) {
|
||||
if (obj === undefined || obj === null)
|
||||
return obj;
|
||||
|
||||
if (Array.isArray(obj))
|
||||
return exports.cloneArray(obj, options);
|
||||
|
||||
if (obj.constructor) {
|
||||
if (/ObjectI[dD]$/.test(obj.constructor.name)) {
|
||||
return 'function' == typeof obj.clone
|
||||
? obj.clone()
|
||||
: new obj.constructor(obj.id);
|
||||
}
|
||||
|
||||
if (obj.constructor.name === 'ReadPreference') {
|
||||
return new obj.constructor(obj.mode, clone(obj.tags, options));
|
||||
}
|
||||
|
||||
if ('Binary' == obj._bsontype && obj.buffer && obj.value) {
|
||||
return 'function' == typeof obj.clone
|
||||
? obj.clone()
|
||||
: new obj.constructor(obj.value(true), obj.sub_type);
|
||||
}
|
||||
|
||||
if ('Date' === obj.constructor.name || 'Function' === obj.constructor.name)
|
||||
return new obj.constructor(+obj);
|
||||
|
||||
if ('RegExp' === obj.constructor.name)
|
||||
return new RegExp(obj);
|
||||
|
||||
if ('Buffer' === obj.constructor.name)
|
||||
return Buffer.from(obj);
|
||||
}
|
||||
|
||||
if (isObject(obj))
|
||||
return exports.cloneObject(obj, options);
|
||||
|
||||
if (obj.valueOf)
|
||||
return obj.valueOf();
|
||||
};
|
||||
|
||||
/*!
|
||||
* ignore
|
||||
*/
|
||||
|
||||
exports.cloneObject = function cloneObject(obj, options) {
|
||||
const minimize = options && options.minimize,
|
||||
ret = {},
|
||||
keys = Object.keys(obj),
|
||||
len = keys.length;
|
||||
let hasKeys = false,
|
||||
val,
|
||||
k = '',
|
||||
i = 0;
|
||||
|
||||
for (i = 0; i < len; ++i) {
|
||||
k = keys[i];
|
||||
// Not technically prototype pollution because this wouldn't merge properties
|
||||
// onto `Object.prototype`, but avoid properties like __proto__ as a precaution.
|
||||
if (specialProperties.indexOf(k) !== -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
val = clone(obj[k], options);
|
||||
|
||||
if (!minimize || ('undefined' !== typeof val)) {
|
||||
hasKeys || (hasKeys = true);
|
||||
ret[k] = val;
|
||||
}
|
||||
}
|
||||
|
||||
return minimize
|
||||
? hasKeys && ret
|
||||
: ret;
|
||||
};
|
||||
|
||||
exports.cloneArray = function cloneArray(arr, options) {
|
||||
const ret = [],
|
||||
l = arr.length;
|
||||
let i = 0;
|
||||
for (; i < l; i++)
|
||||
ret.push(clone(arr[i], options));
|
||||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* Merges `from` into `to` without overwriting existing properties.
|
||||
*
|
||||
* @param {Object} to
|
||||
* @param {Object} from
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.merge = function merge(to, from) {
|
||||
const keys = Object.keys(from);
|
||||
|
||||
for (const key of keys) {
|
||||
if (specialProperties.indexOf(key) !== -1) {
|
||||
continue;
|
||||
}
|
||||
if ('undefined' === typeof to[key]) {
|
||||
to[key] = from[key];
|
||||
} else {
|
||||
if (exports.isObject(from[key])) {
|
||||
merge(to[key], from[key]);
|
||||
} else {
|
||||
to[key] = from[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Same as merge but clones the assigned values.
|
||||
*
|
||||
* @param {Object} to
|
||||
* @param {Object} from
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.mergeClone = function mergeClone(to, from) {
|
||||
const keys = Object.keys(from);
|
||||
|
||||
for (const key of keys) {
|
||||
if (specialProperties.indexOf(key) !== -1) {
|
||||
continue;
|
||||
}
|
||||
if ('undefined' === typeof to[key]) {
|
||||
to[key] = clone(from[key]);
|
||||
} else {
|
||||
if (exports.isObject(from[key])) {
|
||||
mergeClone(to[key], from[key]);
|
||||
} else {
|
||||
to[key] = clone(from[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Read pref helper (mongo 2.2 drivers support this)
|
||||
*
|
||||
* Allows using aliases instead of full preference names:
|
||||
*
|
||||
* p primary
|
||||
* pp primaryPreferred
|
||||
* s secondary
|
||||
* sp secondaryPreferred
|
||||
* n nearest
|
||||
*
|
||||
* @param {String} pref
|
||||
*/
|
||||
|
||||
exports.readPref = function readPref(pref) {
|
||||
switch (pref) {
|
||||
case 'p':
|
||||
pref = 'primary';
|
||||
break;
|
||||
case 'pp':
|
||||
pref = 'primaryPreferred';
|
||||
break;
|
||||
case 's':
|
||||
pref = 'secondary';
|
||||
break;
|
||||
case 'sp':
|
||||
pref = 'secondaryPreferred';
|
||||
break;
|
||||
case 'n':
|
||||
pref = 'nearest';
|
||||
break;
|
||||
}
|
||||
|
||||
return pref;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Read Concern helper (mongo 3.2 drivers support this)
|
||||
*
|
||||
* Allows using string to specify read concern level:
|
||||
*
|
||||
* local 3.2+
|
||||
* available 3.6+
|
||||
* majority 3.2+
|
||||
* linearizable 3.4+
|
||||
* snapshot 4.0+
|
||||
*
|
||||
* @param {String|Object} concern
|
||||
*/
|
||||
|
||||
exports.readConcern = function readConcern(concern) {
|
||||
if ('string' === typeof concern) {
|
||||
switch (concern) {
|
||||
case 'l':
|
||||
concern = 'local';
|
||||
break;
|
||||
case 'a':
|
||||
concern = 'available';
|
||||
break;
|
||||
case 'm':
|
||||
concern = 'majority';
|
||||
break;
|
||||
case 'lz':
|
||||
concern = 'linearizable';
|
||||
break;
|
||||
case 's':
|
||||
concern = 'snapshot';
|
||||
break;
|
||||
}
|
||||
concern = { level: concern };
|
||||
}
|
||||
return concern;
|
||||
};
|
||||
|
||||
/**
|
||||
* Object.prototype.toString.call helper
|
||||
*/
|
||||
|
||||
const _toString = Object.prototype.toString;
|
||||
exports.toString = function(arg) {
|
||||
return _toString.call(arg);
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines if `arg` is an object.
|
||||
*
|
||||
* @param {Object|Array|String|Function|RegExp|any} arg
|
||||
* @return {Boolean}
|
||||
*/
|
||||
|
||||
const isObject = exports.isObject = function(arg) {
|
||||
return '[object Object]' == exports.toString(arg);
|
||||
};
|
||||
|
||||
/**
|
||||
* Object.keys helper
|
||||
*/
|
||||
|
||||
exports.keys = Object.keys;
|
||||
|
||||
/**
|
||||
* Basic Object.create polyfill.
|
||||
* Only one argument is supported.
|
||||
*
|
||||
* Based on https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/create
|
||||
*/
|
||||
|
||||
exports.create = 'function' == typeof Object.create
|
||||
? Object.create
|
||||
: create;
|
||||
|
||||
function create(proto) {
|
||||
if (arguments.length > 1) {
|
||||
throw new Error('Adding properties is not supported');
|
||||
}
|
||||
|
||||
function F() { }
|
||||
F.prototype = proto;
|
||||
return new F;
|
||||
}
|
||||
|
||||
/**
|
||||
* inheritance
|
||||
*/
|
||||
|
||||
exports.inherits = function(ctor, superCtor) {
|
||||
ctor.prototype = exports.create(superCtor.prototype);
|
||||
ctor.prototype.constructor = ctor;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if this object is an arguments object
|
||||
*
|
||||
* @param {Any} v
|
||||
* @return {Boolean}
|
||||
*/
|
||||
|
||||
exports.isArgumentsObject = function(v) {
|
||||
return Object.prototype.toString.call(v) === '[object Arguments]';
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue