summaryrefslogtreecommitdiffstats
path: root/node_modules/mongoose/lib/helpers/indexes
diff options
context:
space:
mode:
authorGravatar Piotr Russ <mail@pruss.it> 2020-11-18 23:26:45 +0100
committerGravatar Piotr Russ <mail@pruss.it> 2020-11-18 23:26:45 +0100
commit81ddf9b700bc48a1f8e472209f080f9c1d9a9b09 (patch)
tree8b959d50c5a614cbf9fcb346ed556140374d4b6d /node_modules/mongoose/lib/helpers/indexes
parent1870f3fdf43707a15fda0f609a021f516f45eb63 (diff)
downloadwebsite_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.tar.gz
website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.tar.bz2
website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.zip
rm node_modules
Diffstat (limited to 'node_modules/mongoose/lib/helpers/indexes')
-rw-r--r--node_modules/mongoose/lib/helpers/indexes/isDefaultIdIndex.js18
-rw-r--r--node_modules/mongoose/lib/helpers/indexes/isIndexEqual.js95
2 files changed, 0 insertions, 113 deletions
diff --git a/node_modules/mongoose/lib/helpers/indexes/isDefaultIdIndex.js b/node_modules/mongoose/lib/helpers/indexes/isDefaultIdIndex.js
deleted file mode 100644
index c975dcf..0000000
--- a/node_modules/mongoose/lib/helpers/indexes/isDefaultIdIndex.js
+++ /dev/null
@@ -1,18 +0,0 @@
-'use strict';
-
-const get = require('../get');
-
-module.exports = function isDefaultIdIndex(index) {
- if (Array.isArray(index)) {
- // Mongoose syntax
- const keys = Object.keys(index[0]);
- return keys.length === 1 && keys[0] === '_id' && index[0]._id !== 'hashed';
- }
-
- if (typeof index !== 'object') {
- return false;
- }
-
- const key = get(index, 'key', {});
- return Object.keys(key).length === 1 && key.hasOwnProperty('_id');
-}; \ No newline at end of file
diff --git a/node_modules/mongoose/lib/helpers/indexes/isIndexEqual.js b/node_modules/mongoose/lib/helpers/indexes/isIndexEqual.js
deleted file mode 100644
index d59d734..0000000
--- a/node_modules/mongoose/lib/helpers/indexes/isIndexEqual.js
+++ /dev/null
@@ -1,95 +0,0 @@
-'use strict';
-
-const get = require('../get');
-const utils = require('../../utils');
-
-/**
- * Given a Mongoose index definition (key + options objects) and a MongoDB server
- * index definition, determine if the two indexes are equal.
- *
- * @param {Object} key the Mongoose index spec
- * @param {Object} options the Mongoose index definition's options
- * @param {Object} dbIndex the index in MongoDB as returned by `listIndexes()`
- * @api private
- */
-
-module.exports = function isIndexEqual(key, options, dbIndex) {
- // Special case: text indexes have a special format in the db. For example,
- // `{ name: 'text' }` becomes:
- // {
- // v: 2,
- // key: { _fts: 'text', _ftsx: 1 },
- // name: 'name_text',
- // ns: 'test.tests',
- // background: true,
- // weights: { name: 1 },
- // default_language: 'english',
- // language_override: 'language',
- // textIndexVersion: 3
- // }
- if (dbIndex.textIndexVersion != null) {
- const weights = dbIndex.weights;
- if (Object.keys(weights).length !== Object.keys(key).length) {
- return false;
- }
- for (const prop of Object.keys(weights)) {
- if (!(prop in key)) {
- return false;
- }
- const weight = weights[prop];
- if (weight !== get(options, 'weights.' + prop) && !(weight === 1 && get(options, 'weights.' + prop) == null)) {
- return false;
- }
- }
-
- if (options['default_language'] !== dbIndex['default_language']) {
- return dbIndex['default_language'] === 'english' && options['default_language'] == null;
- }
-
- return true;
- }
-
- const optionKeys = [
- 'unique',
- 'partialFilterExpression',
- 'sparse',
- 'expireAfterSeconds',
- 'collation'
- ];
- for (const key of optionKeys) {
- if (!(key in options) && !(key in dbIndex)) {
- continue;
- }
- if (key === 'collation') {
- if (options[key] == null || dbIndex[key] == null) {
- return options[key] == null && dbIndex[key] == null;
- }
- const definedKeys = Object.keys(options.collation);
- const schemaCollation = options.collation;
- const dbCollation = dbIndex.collation;
- for (const opt of definedKeys) {
- if (get(schemaCollation, opt) !== get(dbCollation, opt)) {
- return false;
- }
- }
- } else if (!utils.deepEqual(options[key], dbIndex[key])) {
- return false;
- }
- }
-
- const schemaIndexKeys = Object.keys(key);
- const dbIndexKeys = Object.keys(dbIndex.key);
- if (schemaIndexKeys.length !== dbIndexKeys.length) {
- return false;
- }
- for (let i = 0; i < schemaIndexKeys.length; ++i) {
- if (schemaIndexKeys[i] !== dbIndexKeys[i]) {
- return false;
- }
- if (!utils.deepEqual(key[schemaIndexKeys[i]], dbIndex.key[dbIndexKeys[i]])) {
- return false;
- }
- }
-
- return true;
-};