repo stringlengths 5 106 | file_url stringlengths 78 301 | file_path stringlengths 4 211 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:56:49 2026-01-05 02:23:25 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/populate/getVirtual.js | lib/helpers/populate/getVirtual.js | 'use strict';
module.exports = getVirtual;
/*!
* ignore
*/
function getVirtual(schema, name) {
if (schema.virtuals[name]) {
return { virtual: schema.virtuals[name], path: void 0 };
}
const parts = name.split('.');
let cur = '';
let nestedSchemaPath = '';
for (let i = 0; i < parts.length; ++i) {
... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/populate/markArraySubdocsPopulated.js | lib/helpers/populate/markArraySubdocsPopulated.js | 'use strict';
const utils = require('../../utils');
/**
* If populating a path within a document array, make sure each
* subdoc within the array knows its subpaths are populated.
*
* #### Example:
*
* const doc = await Article.findOne().populate('comments.author');
* doc.comments[0].populated('author')... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/populate/createPopulateQueryFilter.js | lib/helpers/populate/createPopulateQueryFilter.js | 'use strict';
const SkipPopulateValue = require('./skipPopulateValue');
const parentPaths = require('../path/parentPaths');
const { trusted } = require('../query/trusted');
const hasDollarKeys = require('../query/hasDollarKeys');
module.exports = function createPopulateQueryFilter(ids, _match, _foreignField, model, s... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/populate/lookupLocalFields.js | lib/helpers/populate/lookupLocalFields.js | 'use strict';
module.exports = function lookupLocalFields(cur, path, val) {
if (cur == null) {
return cur;
}
if (cur._doc != null) {
cur = cur._doc;
}
if (arguments.length >= 3) {
if (typeof cur !== 'object') {
return void 0;
}
if (val === void 0) {
return void 0;
}
... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/populate/modelNamesFromRefPath.js | lib/helpers/populate/modelNamesFromRefPath.js | 'use strict';
const MongooseError = require('../../error/mongooseError');
const isPathExcluded = require('../projection/isPathExcluded');
const lookupLocalFields = require('./lookupLocalFields');
const mpath = require('mpath');
const util = require('util');
const utils = require('../../utils');
const hasNumericPropRE... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/populate/removeDeselectedForeignField.js | lib/helpers/populate/removeDeselectedForeignField.js | 'use strict';
const get = require('../get');
const mpath = require('mpath');
const parseProjection = require('../projection/parseProjection');
/*!
* ignore
*/
module.exports = function removeDeselectedForeignField(foreignFields, options, docs) {
const projection = parseProjection(get(options, 'select', null), tr... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/populate/getModelsMapForPopulate.js | lib/helpers/populate/getModelsMapForPopulate.js | 'use strict';
const MongooseError = require('../../error/index');
const SkipPopulateValue = require('./skipPopulateValue');
const clone = require('../clone');
const get = require('../get');
const getDiscriminatorByValue = require('../discriminator/getDiscriminatorByValue');
const getConstructorName = require('../getCo... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/populate/setPopulatedVirtualValue.js | lib/helpers/populate/setPopulatedVirtualValue.js | 'use strict';
/**
* Set a populated virtual value on a document's `$$populatedVirtuals` value
*
* @param {*} populatedVirtuals A document's `$$populatedVirtuals`
* @param {*} name The virtual name
* @param {*} v The result of the populate query
* @param {*} options The populate options. This function handles `ju... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/populate/skipPopulateValue.js | lib/helpers/populate/skipPopulateValue.js | 'use strict';
module.exports = function SkipPopulateValue(val) {
if (!(this instanceof SkipPopulateValue)) {
return new SkipPopulateValue(val);
}
this.val = val;
return this;
};
| javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/update/updatedPathsByArrayFilter.js | lib/helpers/update/updatedPathsByArrayFilter.js | 'use strict';
const modifiedPaths = require('./modifiedPaths');
module.exports = function updatedPathsByArrayFilter(update) {
if (update == null) {
return {};
}
const updatedPaths = modifiedPaths(update);
return Object.keys(updatedPaths).reduce((cur, path) => {
const matches = path.match(/\$\[[^\]]+\... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/update/applyTimestampsToUpdate.js | lib/helpers/update/applyTimestampsToUpdate.js | 'use strict';
/*!
* ignore
*/
const get = require('../get');
const utils = require('../../utils');
module.exports = applyTimestampsToUpdate;
/*!
* ignore
*/
function applyTimestampsToUpdate(now, createdAt, updatedAt, currentUpdate, options, isReplace) {
const updates = currentUpdate;
let _updates = updates... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/update/modifiedPaths.js | lib/helpers/update/modifiedPaths.js | 'use strict';
const _modifiedPaths = require('../common').modifiedPaths;
/**
* Given an update document with potential update operators (`$set`, etc.)
* returns an object whose keys are the directly modified paths.
*
* If there are any top-level keys that don't start with `$`, we assume those
* will get wrapped ... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/update/moveImmutableProperties.js | lib/helpers/update/moveImmutableProperties.js | 'use strict';
const get = require('../get');
/**
* Given an update, move all $set on immutable properties to $setOnInsert.
* This should only be called for upserts, because $setOnInsert bypasses the
* strictness check for immutable properties.
*/
module.exports = function moveImmutableProperties(schema, update, ... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/update/applyTimestampsToChildren.js | lib/helpers/update/applyTimestampsToChildren.js | 'use strict';
const cleanPositionalOperators = require('../schema/cleanPositionalOperators');
const handleTimestampOption = require('../schema/handleTimestampOption');
module.exports = applyTimestampsToChildren;
/*!
* ignore
*/
function applyTimestampsToChildren(now, update, schema) {
if (update == null) {
... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/update/castArrayFilters.js | lib/helpers/update/castArrayFilters.js | 'use strict';
const castFilterPath = require('../query/castFilterPath');
const cleanPositionalOperators = require('../schema/cleanPositionalOperators');
const getPath = require('../schema/getPath');
const updatedPathsByArrayFilter = require('./updatedPathsByArrayFilter');
const utils = require('../../utils');
module.... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/update/decorateUpdateWithVersionKey.js | lib/helpers/update/decorateUpdateWithVersionKey.js | 'use strict';
/**
* Decorate the update with a version key, if necessary
* @api private
*/
module.exports = function decorateUpdateWithVersionKey(update, options, versionKey) {
if (!versionKey || !options?.upsert) {
return;
}
if (options.overwrite) {
if (!hasKey(update, versionKey)) {
update[v... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/update/removeUnusedArrayFilters.js | lib/helpers/update/removeUnusedArrayFilters.js | 'use strict';
/**
* MongoDB throws an error if there's unused array filters. That is, if `options.arrayFilters` defines
* a filter, but none of the `update` keys use it. This should be enough to filter out all unused array
* filters.
*/
module.exports = function removeUnusedArrayFilters(update, arrayFilters) {
... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/document/compile.js | lib/helpers/document/compile.js | 'use strict';
const clone = require('../../helpers/clone');
const documentSchemaSymbol = require('../../helpers/symbols').documentSchemaSymbol;
const internalToObjectOptions = require('../../options').internalToObjectOptions;
const utils = require('../../utils');
let Document;
const getSymbol = require('../../helpers... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/document/getEmbeddedDiscriminatorPath.js | lib/helpers/document/getEmbeddedDiscriminatorPath.js | 'use strict';
const get = require('../get');
const getSchemaDiscriminatorByValue = require('../discriminator/getSchemaDiscriminatorByValue');
/**
* Like `schema.path()`, except with a document, because impossible to
* determine path type without knowing the embedded discriminator key.
*
* @param {Document} doc
*... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/document/applyVirtuals.js | lib/helpers/document/applyVirtuals.js | 'use strict';
const mpath = require('mpath');
const utils = require('../../utils');
module.exports = applyVirtuals;
/**
* Apply a given schema's virtuals to a given POJO
*
* @param {Schema} schema
* @param {Object} obj
* @param {Array<string>} [virtuals] optional whitelist of virtuals to apply
* @returns
*/
... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/document/getDeepestSubdocumentForPath.js | lib/helpers/document/getDeepestSubdocumentForPath.js | 'use strict';
/**
* Find the deepest subdocument along a given path to ensure setter functions run
* with the correct subdocument as `this`. If no subdocuments, returns the top-level
* document.
*
* @param {Document} doc
* @param {String[]} parts
* @param {Schema} schema
* @returns Document
*/
module.exports... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/document/applyTimestamps.js | lib/helpers/document/applyTimestamps.js | 'use strict';
const handleTimestampOption = require('../schema/handleTimestampOption');
const mpath = require('mpath');
const utils = require('../../utils');
module.exports = applyTimestamps;
/**
* Apply a given schema's timestamps to the given POJO
*
* @param {Schema} schema
* @param {Object} obj
* @param {Obj... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/document/cleanModifiedSubpaths.js | lib/helpers/document/cleanModifiedSubpaths.js | 'use strict';
/*!
* ignore
*/
module.exports = function cleanModifiedSubpaths(doc, path, options) {
options = options || {};
const skipDocArrays = options.skipDocArrays;
let deleted = 0;
if (!doc) {
return deleted;
}
for (const modifiedPath of Object.keys(doc.$__.activePaths.getStatePaths('modify'... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/document/applyDefaults.js | lib/helpers/document/applyDefaults.js | 'use strict';
const isNestedProjection = require('../projection/isNestedProjection');
module.exports = function applyDefaults(doc, fields, exclude, hasIncludedChildren, isBeforeSetters, pathsToSkip, options) {
const paths = Object.keys(doc.$__schema.paths);
const plen = paths.length;
const skipParentChangeTrack... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/document/handleSpreadDoc.js | lib/helpers/document/handleSpreadDoc.js | 'use strict';
const utils = require('../../utils');
const keysToSkip = new Set(['__index', '__parentArray', '_doc']);
/**
* Using spread operator on a Mongoose document gives you a
* POJO that has a tendency to cause infinite recursion. So
* we use this function on `set()` to prevent that.
*/
module.exports = f... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/path/parentPaths.js | lib/helpers/path/parentPaths.js | 'use strict';
const dotRE = /\./g;
module.exports = function parentPaths(path) {
if (path.indexOf('.') === -1) {
return [path];
}
const pieces = path.split(dotRE);
const len = pieces.length;
const ret = new Array(len);
let cur = '';
for (let i = 0; i < len; ++i) {
cur += (cur.length !== 0) ? '.' ... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/path/setDottedPath.js | lib/helpers/path/setDottedPath.js | 'use strict';
const specialProperties = require('../specialProperties');
module.exports = function setDottedPath(obj, path, val) {
if (path.indexOf('.') === -1) {
if (specialProperties.has(path)) {
return;
}
obj[path] = val;
return;
}
const parts = path.split('.');
const last = parts.... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/schematype/handleImmutable.js | lib/helpers/schematype/handleImmutable.js | 'use strict';
const StrictModeError = require('../../error/strict');
/*!
* ignore
*/
module.exports = function(schematype) {
if (schematype.$immutable) {
schematype.$immutableSetter = createImmutableSetter(schematype.path,
schematype.options.immutable);
schematype.set(schematype.$immutableSetter);
... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/schema/applyWriteConcern.js | lib/helpers/schema/applyWriteConcern.js | 'use strict';
const utils = require('../../utils');
module.exports = function applyWriteConcern(schema, options) {
if (options.writeConcern != null) {
return;
}
// Don't apply default write concern to operations in transactions,
// because setting write concern on an operation in a transaction is an error... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/schema/applyPlugins.js | lib/helpers/schema/applyPlugins.js | 'use strict';
module.exports = function applyPlugins(schema, plugins, options, cacheKey) {
if (schema[cacheKey]) {
return;
}
schema[cacheKey] = true;
if (!options?.skipTopLevel) {
let pluginTags = null;
for (const plugin of plugins) {
const tags = plugin[1] == null ? null : plugin[1].tags;
... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/schema/handleTimestampOption.js | lib/helpers/schema/handleTimestampOption.js | 'use strict';
module.exports = handleTimestampOption;
/*!
* ignore
*/
function handleTimestampOption(arg, prop) {
if (arg == null) {
return null;
}
if (typeof arg === 'boolean') {
return prop;
}
if (typeof arg[prop] === 'boolean') {
return arg[prop] ? prop : null;
}
if (!(prop in arg)) {... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/schema/merge.js | lib/helpers/schema/merge.js | 'use strict';
module.exports = function merge(s1, s2, skipConflictingPaths) {
const paths = Object.keys(s2.tree);
const pathsToAdd = {};
for (const key of paths) {
if (skipConflictingPaths && (s1.paths[key] || s1.nested[key] || s1.singleNestedPaths[key])) {
continue;
}
pathsToAdd[key] = s2.tree... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/schema/applyReadConcern.js | lib/helpers/schema/applyReadConcern.js | 'use strict';
module.exports = function applyReadConcern(schema, options) {
if (options.readConcern !== undefined) {
return;
}
// Don't apply default read concern to operations in transactions,
// because you shouldn't set read concern on individual operations
// within a transaction.
// See: https://... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/schema/handleIdOption.js | lib/helpers/schema/handleIdOption.js | 'use strict';
const addAutoId = require('./addAutoId');
module.exports = function handleIdOption(schema, options) {
if (options?._id == null) {
return schema;
}
schema = schema.clone();
if (!options._id) {
schema.remove('_id');
schema.options._id = false;
} else if (!schema.paths['_id']) {
... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/schema/cleanPositionalOperators.js | lib/helpers/schema/cleanPositionalOperators.js | 'use strict';
/**
* For consistency's sake, we replace positional operator `$` and array filters
* `$[]` and `$[foo]` with `0` when looking up schema paths.
*/
module.exports = function cleanPositionalOperators(path) {
return path.
replace(/\.\$(\[[^\]]*\])?(?=\.)/g, '.0').
replace(/\.\$(\[[^\]]*\])?$/g,... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/schema/addAutoId.js | lib/helpers/schema/addAutoId.js | 'use strict';
module.exports = function addAutoId(schema) {
const _obj = { _id: { auto: true } };
_obj._id[schema.options.typeKey] = 'ObjectId';
schema.add(_obj);
};
| javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/schema/getKeysInSchemaOrder.js | lib/helpers/schema/getKeysInSchemaOrder.js | 'use strict';
const get = require('../get');
module.exports = function getKeysInSchemaOrder(schema, val, path) {
const schemaKeys = path != null ? Object.keys(get(schema.tree, path, {})) : Object.keys(schema.tree);
const valKeys = new Set(Object.keys(val));
let keys;
if (valKeys.size > 1) {
keys = new Se... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/schema/getPath.js | lib/helpers/schema/getPath.js | 'use strict';
const numberRE = /^\d+$/;
/**
* Behaves like `Schema#path()`, except for it also digs into arrays without
* needing to put `.0.`, so `getPath(schema, 'docArr.elProp')` works.
* @api private
*/
module.exports = function getPath(schema, path, discriminatorValueMap) {
let schematype = schema.path(pa... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/schema/idGetter.js | lib/helpers/schema/idGetter.js | 'use strict';
/*!
* ignore
*/
module.exports = function addIdGetter(schema) {
// ensure the documents receive an id getter unless disabled
const autoIdGetter = !schema.paths['id'] &&
schema.paths['_id'] &&
schema.options.id;
if (!autoIdGetter) {
return schema;
}
if (schema.aliases?.id) {
r... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/schema/getIndexes.js | lib/helpers/schema/getIndexes.js | 'use strict';
const get = require('../get');
const helperIsObject = require('../isObject');
const decorateDiscriminatorIndexOptions = require('../indexes/decorateDiscriminatorIndexOptions');
/**
* Gather all indexes defined in the schema, including single nested,
* document arrays, and embedded discriminators.
* @... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/schema/applyBuiltinPlugins.js | lib/helpers/schema/applyBuiltinPlugins.js | 'use strict';
const builtinPlugins = require('../../plugins');
module.exports = function applyBuiltinPlugins(schema) {
for (const plugin of Object.values(builtinPlugins)) {
plugin(schema, { deduplicate: true });
}
schema.plugins = Object.values(builtinPlugins).
map(fn => ({ fn, opts: { deduplicate: true... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/schema/getSubdocumentStrictValue.js | lib/helpers/schema/getSubdocumentStrictValue.js | 'use strict';
/**
* Find the `strict` mode setting for the deepest subdocument along a given path
* to ensure we have the correct default value for `strict`. When setting values
* underneath a subdocument, we should use the subdocument's `strict` setting by
* default, not the top-level document's.
*
* @param {Sc... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/indexes/applySchemaCollation.js | lib/helpers/indexes/applySchemaCollation.js | 'use strict';
const isTextIndex = require('./isTextIndex');
module.exports = function applySchemaCollation(indexKeys, indexOptions, schemaOptions) {
if (isTextIndex(indexKeys)) {
return;
}
if (Object.hasOwn(schemaOptions, 'collation') && !Object.hasOwn(indexOptions, 'collation')) {
indexOptions.collati... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js | lib/helpers/indexes/decorateDiscriminatorIndexOptions.js | 'use strict';
module.exports = function decorateDiscriminatorIndexOptions(schema, indexOptions) {
// If the model is a discriminator and has an index, add a
// partialFilterExpression by default so the index will only apply
// to that discriminator.
const discriminatorName = schema.discriminatorMapping?.value;... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/indexes/getRelatedIndexes.js | lib/helpers/indexes/getRelatedIndexes.js | 'use strict';
const hasDollarKeys = require('../query/hasDollarKeys');
function getRelatedSchemaIndexes(model, schemaIndexes) {
return getRelatedIndexes({
baseModelName: model.baseModelName,
discriminatorMapping: model.schema.discriminatorMapping,
indexes: schemaIndexes,
indexesType: 'schema'
});
... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/indexes/isIndexSpecEqual.js | lib/helpers/indexes/isIndexSpecEqual.js | 'use strict';
/**
* Compares two index specifications to determine if they are equal.
*
* #### Example:
* isIndexSpecEqual({ a: 1, b: 1 }, { a: 1, b: 1 }); // true
* isIndexSpecEqual({ a: 1, b: 1 }, { b: 1, a: 1 }); // false
* isIndexSpecEqual({ a: 1, b: -1 }, { a: 1, b: 1 }); // false
*
* @param {... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/indexes/isDefaultIdIndex.js | lib/helpers/indexes/isDefaultIdIndex.js | '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') {
retu... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/indexes/isTextIndex.js | lib/helpers/indexes/isTextIndex.js | 'use strict';
/**
* Returns `true` if the given index options have a `text` option.
*/
module.exports = function isTextIndex(indexKeys) {
let isTextIndex = false;
for (const key of Object.keys(indexKeys)) {
if (indexKeys[key] === 'text') {
isTextIndex = true;
}
}
return isTextIndex;
};
| javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/indexes/isTimeseriesIndex.js | lib/helpers/indexes/isTimeseriesIndex.js | 'use strict';
/**
* Returns `true` if the given index matches the schema's `timestamps` options
*/
module.exports = function isTimeseriesIndex(dbIndex, schemaOptions) {
if (schemaOptions.timeseries == null) {
return false;
}
const { timeField, metaField } = schemaOptions.timeseries;
if (typeof timeField... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/indexes/isIndexEqual.js | lib/helpers/indexes/isIndexEqual.js | '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} schemaIndexKeysObject the Mongoose index spec
* @param {Object} op... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/timestamps/setDocumentTimestamps.js | lib/helpers/timestamps/setDocumentTimestamps.js | 'use strict';
module.exports = function setDocumentTimestamps(doc, timestampOption, currentTime, createdAt, updatedAt) {
const skipUpdatedAt = timestampOption?.updatedAt === false;
const skipCreatedAt = timestampOption?.createdAt === false;
const defaultTimestamp = currentTime != null ?
currentTime() :
... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/helpers/timestamps/setupTimestamps.js | lib/helpers/timestamps/setupTimestamps.js | 'use strict';
const applyTimestampsToChildren = require('../update/applyTimestampsToChildren');
const applyTimestampsToUpdate = require('../update/applyTimestampsToUpdate');
const get = require('../get');
const handleTimestampOption = require('../schema/handleTimestampOption');
const setDocumentTimestamps = require('.... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/plugins/index.js | lib/plugins/index.js | 'use strict';
exports.saveSubdocs = require('./saveSubdocs');
exports.sharding = require('./sharding');
exports.trackTransaction = require('./trackTransaction');
exports.validateBeforeSave = require('./validateBeforeSave');
| javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/plugins/saveSubdocs.js | lib/plugins/saveSubdocs.js | 'use strict';
/*!
* ignore
*/
module.exports = function saveSubdocs(schema) {
const unshift = true;
schema.s.hooks.pre('save', false, async function saveSubdocsPreSave() {
if (this.$isSubdocument) {
return;
}
const subdocs = this.$getAllSubdocs({ useCache: true });
if (!subdocs.length) {... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/plugins/trackTransaction.js | lib/plugins/trackTransaction.js | 'use strict';
const arrayAtomicsSymbol = require('../helpers/symbols').arrayAtomicsSymbol;
const sessionNewDocuments = require('../helpers/symbols').sessionNewDocuments;
const utils = require('../utils');
module.exports = function trackTransaction(schema) {
schema.pre('save', function trackTransactionPreSave() {
... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/plugins/validateBeforeSave.js | lib/plugins/validateBeforeSave.js | 'use strict';
/*!
* ignore
*/
module.exports = function validateBeforeSave(schema) {
const unshift = true;
schema.pre('save', false, async function validateBeforeSave(options) {
// Nested docs have their own presave
if (this.$isSubdocument) {
return;
}
const hasValidateBeforeSaveOption = ... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/plugins/sharding.js | lib/plugins/sharding.js | 'use strict';
const objectIdSymbol = require('../helpers/symbols').objectIdSymbol;
const utils = require('../utils');
/*!
* ignore
*/
module.exports = function shardingPlugin(schema) {
schema.post('init', function shardingPluginPostInit() {
storeShard.call(this);
return this;
});
schema.pre('save', f... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/types/uuid.js | lib/types/uuid.js | /**
* UUID type constructor
*
* #### Example:
*
* const id = new mongoose.Types.UUID();
*
* @constructor UUID
*/
'use strict';
module.exports = require('mongodb/lib/bson').UUID;
| javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/types/buffer.js | lib/types/buffer.js | /*!
* Module dependencies.
*/
'use strict';
const Binary = require('mongodb/lib/bson').Binary;
const UUID = require('mongodb/lib/bson').UUID;
const utils = require('../utils');
/**
* Mongoose Buffer constructor.
*
* Values always have to be passed to the constructor to initialize.
*
* @param {Buffer} value
*... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/types/map.js | lib/types/map.js | 'use strict';
const MongooseError = require('../error/mongooseError');
const clone = require('../helpers/clone');
const deepEqual = require('../utils').deepEqual;
const getConstructorName = require('../helpers/getConstructorName');
const handleSpreadDoc = require('../helpers/document/handleSpreadDoc');
const util = re... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/types/objectid.js | lib/types/objectid.js | /**
* ObjectId type constructor
*
* #### Example:
*
* const id = new mongoose.Types.ObjectId;
*
* @constructor ObjectId
*/
'use strict';
const ObjectId = require('mongodb/lib/bson').ObjectId;
const objectIdSymbol = require('../helpers/symbols').objectIdSymbol;
/**
* Getter for convenience with populate,... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/types/index.js | lib/types/index.js |
/*!
* Module exports.
*/
'use strict';
exports.Array = require('./array');
exports.Buffer = require('./buffer');
exports.Document = // @deprecate
exports.Embedded = require('./arraySubdocument');
exports.DocumentArray = require('./documentArray');
exports.Double = require('./double');
exports.Decimal128 = requir... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/types/arraySubdocument.js | lib/types/arraySubdocument.js | /*!
* Module dependencies.
*/
'use strict';
const EventEmitter = require('events').EventEmitter;
const Subdocument = require('./subdocument');
const utils = require('../utils');
const documentArrayParent = require('../helpers/symbols').documentArrayParent;
/**
* A constructor.
*
* @param {Object} obj js object... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/types/subdocument.js | lib/types/subdocument.js | 'use strict';
const Document = require('../document');
const internalToObjectOptions = require('../options').internalToObjectOptions;
const util = require('util');
const utils = require('../utils');
module.exports = Subdocument;
/**
* Subdocument constructor.
*
* @inherits Document
* @api private
*/
function S... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/types/decimal128.js | lib/types/decimal128.js | /**
* Decimal128 type constructor
*
* #### Example:
*
* const id = new mongoose.Types.Decimal128('3.1415');
*
* @constructor Decimal128
*/
'use strict';
module.exports = require('mongodb/lib/bson').Decimal128;
| javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/types/double.js | lib/types/double.js | /**
* Double type constructor
*
* #### Example:
*
* const pi = new mongoose.Types.Double(3.1415);
*
* @constructor Double
*/
'use strict';
module.exports = require('mongodb/lib/bson').Double;
| javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/types/documentArray/isMongooseDocumentArray.js | lib/types/documentArray/isMongooseDocumentArray.js | 'use strict';
exports.isMongooseDocumentArray = function(mongooseDocumentArray) {
return Array.isArray(mongooseDocumentArray) && mongooseDocumentArray.isMongooseDocumentArray;
};
| javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/types/documentArray/index.js | lib/types/documentArray/index.js | 'use strict';
/*!
* Module dependencies.
*/
const ArrayMethods = require('../array/methods');
const DocumentArrayMethods = require('./methods');
const arrayAtomicsSymbol = require('../../helpers/symbols').arrayAtomicsSymbol;
const arrayAtomicsBackupSymbol = require('../../helpers/symbols').arrayAtomicsBackupSymbol... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/types/documentArray/methods/index.js | lib/types/documentArray/methods/index.js | 'use strict';
const ArrayMethods = require('../../array/methods');
const Document = require('../../../document');
const getDiscriminatorByValue = require('../../../helpers/discriminator/getDiscriminatorByValue');
const internalToObjectOptions = require('../../../options').internalToObjectOptions;
const utils = require... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/types/array/index.js | lib/types/array/index.js | /*!
* Module dependencies.
*/
'use strict';
const mongooseArrayMethods = require('./methods');
const arrayAtomicsSymbol = require('../../helpers/symbols').arrayAtomicsSymbol;
const arrayAtomicsBackupSymbol = require('../../helpers/symbols').arrayAtomicsBackupSymbol;
const arrayParentSymbol = require('../../helpers... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/types/array/isMongooseArray.js | lib/types/array/isMongooseArray.js | 'use strict';
exports.isMongooseArray = function(mongooseArray) {
return Array.isArray(mongooseArray) && mongooseArray.isMongooseArray;
};
| javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/types/array/methods/index.js | lib/types/array/methods/index.js | 'use strict';
const Document = require('../../../document');
const ArraySubdocument = require('../../arraySubdocument');
const MongooseError = require('../../../error/mongooseError');
const cleanModifiedSubpaths = require('../../../helpers/document/cleanModifiedSubpaths');
const clone = require('../../../helpers/clone... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/drivers/node-mongodb-native/index.js | lib/drivers/node-mongodb-native/index.js | /*!
* Module exports.
*/
'use strict';
exports.BulkWriteResult = require('./bulkWriteResult');
exports.Collection = require('./collection');
exports.Connection = require('./connection');
exports.ClientEncryption = require('mongodb').ClientEncryption;
| javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/drivers/node-mongodb-native/collection.js | lib/drivers/node-mongodb-native/collection.js | 'use strict';
/*!
* Module dependencies.
*/
const MongooseCollection = require('../../collection');
const MongooseError = require('../../error/mongooseError');
const Collection = require('mongodb').Collection;
const ObjectId = require('../../types/objectid');
const getConstructorName = require('../../helpers/getCon... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/drivers/node-mongodb-native/connection.js | lib/drivers/node-mongodb-native/connection.js | /*!
* Module dependencies.
*/
'use strict';
const MongooseConnection = require('../../connection');
const MongooseError = require('../../error/index');
const STATES = require('../../connectionState');
const mongodb = require('mongodb');
const pkg = require('../../../package.json');
const processConnectionOptions = ... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/drivers/node-mongodb-native/bulkWriteResult.js | lib/drivers/node-mongodb-native/bulkWriteResult.js | 'use strict';
const BulkWriteResult = require('mongodb/lib/bulk/common').BulkWriteResult;
module.exports = BulkWriteResult;
| javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/symbols.js | lib/schema/symbols.js | 'use strict';
exports.schemaMixedSymbol = Symbol.for('mongoose:schema_mixed');
exports.builtInMiddleware = Symbol.for('mongoose:built-in-middleware');
| javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/uuid.js | lib/schema/uuid.js | /*!
* Module dependencies.
*/
'use strict';
const SchemaType = require('../schemaType');
const CastError = SchemaType.CastError;
const castUUID = require('../cast/uuid');
const createJSONSchemaTypeDefinition = require('../helpers/createJSONSchemaTypeDefinition');
const utils = require('../utils');
const handleBitwi... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/buffer.js | lib/schema/buffer.js | /*!
* Module dependencies.
*/
'use strict';
const MongooseBuffer = require('../types/buffer');
const SchemaBufferOptions = require('../options/schemaBufferOptions');
const SchemaType = require('../schemaType');
const createJSONSchemaTypeDefinition = require('../helpers/createJSONSchemaTypeDefinition');
const handle... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/string.js | lib/schema/string.js | 'use strict';
/*!
* Module dependencies.
*/
const SchemaType = require('../schemaType');
const MongooseError = require('../error/index');
const SchemaStringOptions = require('../options/schemaStringOptions');
const castString = require('../cast/string');
const createJSONSchemaTypeDefinition = require('../helpers/cr... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/documentArrayElement.js | lib/schema/documentArrayElement.js | /*!
* Module dependencies.
*/
'use strict';
const MongooseError = require('../error/mongooseError');
const SchemaType = require('../schemaType');
const SchemaSubdocument = require('./subdocument');
const getConstructor = require('../helpers/discriminator/getConstructor');
/**
* DocumentArrayElement SchemaType con... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/map.js | lib/schema/map.js | 'use strict';
/*!
* ignore
*/
const MongooseMap = require('../types/map');
const SchemaMapOptions = require('../options/schemaMapOptions');
const SchemaType = require('../schemaType');
const createJSONSchemaTypeDefinition = require('../helpers/createJSONSchemaTypeDefinition');
const MongooseError = require('../erro... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/int32.js | lib/schema/int32.js | 'use strict';
/*!
* Module dependencies.
*/
const CastError = require('../error/cast');
const SchemaType = require('../schemaType');
const castInt32 = require('../cast/int32');
const createJSONSchemaTypeDefinition = require('../helpers/createJSONSchemaTypeDefinition');
const handleBitwiseOperator = require('./opera... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/documentArray.js | lib/schema/documentArray.js | 'use strict';
/*!
* Module dependencies.
*/
const CastError = require('../error/cast');
const DocumentArrayElement = require('./documentArrayElement');
const EventEmitter = require('events').EventEmitter;
const SchemaArray = require('./array');
const SchemaDocumentArrayOptions =
require('../options/schemaDocument... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/index.js | lib/schema/index.js |
/*!
* Module exports.
*/
'use strict';
exports.Array = require('./array');
exports.BigInt = require('./bigint');
exports.Boolean = require('./boolean');
exports.Buffer = require('./buffer');
exports.Date = require('./date');
exports.Decimal128 = exports.Decimal = require('./decimal128');
exports.DocumentArray = re... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/mixed.js | lib/schema/mixed.js | /*!
* Module dependencies.
*/
'use strict';
const SchemaType = require('../schemaType');
const symbols = require('./symbols');
const isObject = require('../helpers/isObject');
const utils = require('../utils');
/**
* Mixed SchemaType constructor.
*
* @param {String} path
* @param {Object} options
* @param {Ob... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/subdocument.js | lib/schema/subdocument.js | 'use strict';
/*!
* Module dependencies.
*/
const CastError = require('../error/cast');
const EventEmitter = require('events').EventEmitter;
const ObjectExpectedError = require('../error/objectExpected');
const SchemaSubdocumentOptions = require('../options/schemaSubdocumentOptions');
const SchemaType = require('..... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/bigint.js | lib/schema/bigint.js | 'use strict';
/*!
* Module dependencies.
*/
const CastError = require('../error/cast');
const SchemaType = require('../schemaType');
const castBigInt = require('../cast/bigint');
const createJSONSchemaTypeDefinition = require('../helpers/createJSONSchemaTypeDefinition');
/**
* BigInt SchemaType constructor.
*
*... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/decimal128.js | lib/schema/decimal128.js | /*!
* Module dependencies.
*/
'use strict';
const SchemaType = require('../schemaType');
const CastError = SchemaType.CastError;
const castDecimal128 = require('../cast/decimal128');
const createJSONSchemaTypeDefinition = require('../helpers/createJSONSchemaTypeDefinition');
const isBsonType = require('../helpers/i... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/date.js | lib/schema/date.js | /*!
* Module requirements.
*/
'use strict';
const MongooseError = require('../error/index');
const SchemaDateOptions = require('../options/schemaDateOptions');
const SchemaType = require('../schemaType');
const castDate = require('../cast/date');
const createJSONSchemaTypeDefinition = require('../helpers/createJSON... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/array.js | lib/schema/array.js | 'use strict';
/*!
* Module dependencies.
*/
const $exists = require('./operators/exists');
const $type = require('./operators/type');
const MongooseError = require('../error/mongooseError');
const SchemaArrayOptions = require('../options/schemaArrayOptions');
const SchemaType = require('../schemaType');
const CastE... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/objectId.js | lib/schema/objectId.js | /*!
* Module dependencies.
*/
'use strict';
const SchemaObjectIdOptions = require('../options/schemaObjectIdOptions');
const SchemaType = require('../schemaType');
const castObjectId = require('../cast/objectid');
const createJSONSchemaTypeDefinition = require('../helpers/createJSONSchemaTypeDefinition');
const get... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/double.js | lib/schema/double.js | 'use strict';
/*!
* Module dependencies.
*/
const CastError = require('../error/cast');
const SchemaType = require('../schemaType');
const castDouble = require('../cast/double');
const createJSONSchemaTypeDefinition = require('../helpers/createJSONSchemaTypeDefinition');
/**
* Double SchemaType constructor.
*
*... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/number.js | lib/schema/number.js | 'use strict';
/*!
* Module requirements.
*/
const MongooseError = require('../error/index');
const SchemaNumberOptions = require('../options/schemaNumberOptions');
const SchemaType = require('../schemaType');
const castNumber = require('../cast/number');
const createJSONSchemaTypeDefinition = require('../helpers/cr... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/union.js | lib/schema/union.js | 'use strict';
/*!
* ignore
*/
const SchemaUnionOptions = require('../options/schemaUnionOptions');
const SchemaType = require('../schemaType');
const firstValueSymbol = Symbol('firstValue');
/*!
* ignore
*/
class Union extends SchemaType {
/**
* Create a Union schema type.
*
* @param {String} key th... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/boolean.js | lib/schema/boolean.js | 'use strict';
/*!
* Module dependencies.
*/
const CastError = require('../error/cast');
const SchemaType = require('../schemaType');
const castBoolean = require('../cast/boolean');
const createJSONSchemaTypeDefinition = require('../helpers/createJSONSchemaTypeDefinition');
/**
* Boolean SchemaType constructor.
*... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/operators/bitwise.js | lib/schema/operators/bitwise.js | /*!
* Module requirements.
*/
'use strict';
const CastError = require('../../error/cast');
/*!
* ignore
*/
function handleBitwiseOperator(val) {
const _this = this;
if (Array.isArray(val)) {
return val.map(function(v) {
return _castNumber(_this.path, v);
});
} else if (Buffer.isBuffer(val)) ... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/operators/type.js | lib/schema/operators/type.js | 'use strict';
/*!
* ignore
*/
module.exports = function(val) {
if (Array.isArray(val)) {
if (!val.every(v => typeof v === 'number' || typeof v === 'string')) {
throw new Error('$type array values must be strings or numbers');
}
return val;
}
if (typeof val !== 'number' && typeof val !== 'st... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/operators/exists.js | lib/schema/operators/exists.js | 'use strict';
const castBoolean = require('../../cast/boolean');
/*!
* ignore
*/
module.exports = function(val) {
const path = this?.path ?? null;
return castBoolean(val, path);
};
| javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Automattic/mongoose | https://github.com/Automattic/mongoose/blob/f5bfdb54182a1d1bbb5cea6aab87f523713d237c/lib/schema/operators/geospatial.js | lib/schema/operators/geospatial.js | /*!
* Module requirements.
*/
'use strict';
const castArraysOfNumbers = require('./helpers').castArraysOfNumbers;
const castToNumber = require('./helpers').castToNumber;
/*!
* ignore
*/
exports.cast$geoIntersects = cast$geoIntersects;
exports.cast$near = cast$near;
exports.cast$within = cast$within;
function c... | javascript | MIT | f5bfdb54182a1d1bbb5cea6aab87f523713d237c | 2026-01-04T15:02:29.296852Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.