Socket
Socket
Sign inDemoInstall

mongoose

Package Overview
Dependencies
7
Maintainers
4
Versions
868
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 8.0.2 to 8.0.3

lib/helpers/discriminator/applyEmbeddedDiscriminators.js

2

lib/helpers/clone.js

@@ -57,3 +57,3 @@ 'use strict';

if (options && options.minimize && isSingleNested && Object.keys(ret).length === 0) {
if (options && options.minimize && !obj.constructor.$__required && isSingleNested && Object.keys(ret).length === 0) {
return undefined;

@@ -60,0 +60,0 @@ }

@@ -42,4 +42,6 @@ 'use strict';

let i;
let setValueIndex = 0;
function setValue(val) {
++setValueIndex;
if (count) {

@@ -84,2 +86,4 @@ return val;

return valueFilter([val], options, populateOptions, _allIds);
} else if (o.justOne === true && !Array.isArray(val) && Array.isArray(_allIds)) {
return valueFilter(val, options, populateOptions, val == null ? val : _allIds[setValueIndex - 1]);
}

@@ -90,2 +94,3 @@ return valueFilter(val, options, populateOptions, _allIds);

for (i = 0; i < docs.length; ++i) {
setValueIndex = 0;
const _path = o.path.endsWith('.$*') ? o.path.slice(0, -3) : o.path;

@@ -92,0 +97,0 @@ const existingVal = mpath.get(_path, docs[i], lookupLocalFields);

@@ -15,9 +15,8 @@ 'use strict';

const keys = Object.keys(projection);
let ki = keys.length;
let exclude = null;
if (ki === 1 && keys[0] === '_id') {
if (keys.length === 1 && keys[0] === '_id') {
exclude = !projection._id;
} else {
while (ki--) {
for (let ki = 0; ki < keys.length; ++ki) {
// Does this projection explicitly define inclusion/exclusion?

@@ -24,0 +23,0 @@ // Explicitly avoid `$meta` and `$slice`

@@ -33,2 +33,3 @@ 'use strict';

const SetOptionError = require('./error/setOptionError');
const applyEmbeddedDiscriminators = require('./helpers/discriminator/applyEmbeddedDiscriminators');

@@ -631,2 +632,4 @@ const defaultMongooseSymbol = Symbol.for('mongoose:default');

applyEmbeddedDiscriminators(schema);
return model;

@@ -633,0 +636,0 @@ };

@@ -183,7 +183,8 @@ 'use strict';

}
// `_id: 1, name: 0` is a mixed inclusive/exclusive projection in
// MongoDB 4.0 and earlier, but not in later versions.
if (keys[keyIndex] === '_id' && keys.length > 1) {
continue;
}
if (keys[keyIndex] === schema.options.discriminatorKey && keys.length > 1 && field != null && !field) {
continue;
}
exclude = !field;

@@ -190,0 +191,0 @@ break;

@@ -10,3 +10,2 @@ 'use strict';

const castBigInt = require('../cast/bigint');
const utils = require('../utils');

@@ -181,3 +180,4 @@ /**

SchemaBigInt.$conditionalHandlers = utils.options(SchemaType.prototype.$conditionalHandlers, {
SchemaBigInt.$conditionalHandlers = {
...SchemaType.prototype.$conditionalHandlers,
$gt: handleSingle,

@@ -187,3 +187,3 @@ $gte: handleSingle,

$lte: handleSingle
});
};

@@ -190,0 +190,0 @@ /*!

@@ -10,3 +10,2 @@ 'use strict';

const castBoolean = require('../cast/boolean');
const utils = require('../utils');

@@ -239,4 +238,3 @@ /**

SchemaBoolean.$conditionalHandlers =
utils.options(SchemaType.prototype.$conditionalHandlers, {});
SchemaBoolean.$conditionalHandlers = { ...SchemaType.prototype.$conditionalHandlers };

@@ -243,0 +241,0 @@ /**

@@ -253,13 +253,13 @@ /*!

SchemaBuffer.prototype.$conditionalHandlers =
utils.options(SchemaType.prototype.$conditionalHandlers, {
$bitsAllClear: handleBitwiseOperator,
$bitsAnyClear: handleBitwiseOperator,
$bitsAllSet: handleBitwiseOperator,
$bitsAnySet: handleBitwiseOperator,
$gt: handleSingle,
$gte: handleSingle,
$lt: handleSingle,
$lte: handleSingle
});
SchemaBuffer.prototype.$conditionalHandlers = {
...SchemaType.prototype.$conditionalHandlers,
$bitsAllClear: handleBitwiseOperator,
$bitsAnyClear: handleBitwiseOperator,
$bitsAllSet: handleBitwiseOperator,
$bitsAnySet: handleBitwiseOperator,
$gt: handleSingle,
$gte: handleSingle,
$lt: handleSingle,
$lte: handleSingle
};

@@ -266,0 +266,0 @@ /**

@@ -391,9 +391,9 @@ /*!

SchemaDate.prototype.$conditionalHandlers =
utils.options(SchemaType.prototype.$conditionalHandlers, {
$gt: handleSingle,
$gte: handleSingle,
$lt: handleSingle,
$lte: handleSingle
});
SchemaDate.prototype.$conditionalHandlers = {
...SchemaType.prototype.$conditionalHandlers,
$gt: handleSingle,
$gte: handleSingle,
$lt: handleSingle,
$lte: handleSingle
};

@@ -400,0 +400,0 @@

@@ -10,3 +10,2 @@ /*!

const castDecimal128 = require('../cast/decimal128');
const utils = require('../utils');
const isBsonType = require('../helpers/isBsonType');

@@ -218,9 +217,9 @@

SchemaDecimal128.prototype.$conditionalHandlers =
utils.options(SchemaType.prototype.$conditionalHandlers, {
$gt: handleSingle,
$gte: handleSingle,
$lt: handleSingle,
$lte: handleSingle
});
SchemaDecimal128.prototype.$conditionalHandlers = {
...SchemaType.prototype.$conditionalHandlers,
$gt: handleSingle,
$gte: handleSingle,
$lt: handleSingle,
$lte: handleSingle
};

@@ -227,0 +226,0 @@ /*!

@@ -91,8 +91,2 @@ 'use strict';

this.$embeddedSchemaType.schema = this.schema;
if (schema._applyDiscriminators != null && !options?._skipApplyDiscriminators) {
for (const disc of schema._applyDiscriminators.keys()) {
this.discriminator(disc, schema._applyDiscriminators.get(disc));
}
}
}

@@ -532,3 +526,3 @@

const options = Object.assign({}, this.options);
const schematype = new this.constructor(this.path, this.schema, { ...options, _skipApplyDiscriminators: true }, this.schemaOptions);
const schematype = new this.constructor(this.path, this.schema, options, this.schemaOptions);
schematype.validators = this.validators.slice();

@@ -535,0 +529,0 @@ if (this.requiredValidator !== undefined) {

@@ -402,14 +402,14 @@ 'use strict';

SchemaNumber.prototype.$conditionalHandlers =
utils.options(SchemaType.prototype.$conditionalHandlers, {
$bitsAllClear: handleBitwiseOperator,
$bitsAnyClear: handleBitwiseOperator,
$bitsAllSet: handleBitwiseOperator,
$bitsAnySet: handleBitwiseOperator,
$gt: handleSingle,
$gte: handleSingle,
$lt: handleSingle,
$lte: handleSingle,
$mod: handleArray
});
SchemaNumber.prototype.$conditionalHandlers = {
...SchemaType.prototype.$conditionalHandlers,
$bitsAllClear: handleBitwiseOperator,
$bitsAnyClear: handleBitwiseOperator,
$bitsAllSet: handleBitwiseOperator,
$bitsAnySet: handleBitwiseOperator,
$gt: handleSingle,
$gte: handleSingle,
$lt: handleSingle,
$lte: handleSingle,
$mod: handleArray
};

@@ -416,0 +416,0 @@ /**

@@ -262,9 +262,9 @@ /*!

SchemaObjectId.prototype.$conditionalHandlers =
utils.options(SchemaType.prototype.$conditionalHandlers, {
$gt: handleSingle,
$gte: handleSingle,
$lt: handleSingle,
$lte: handleSingle
});
SchemaObjectId.prototype.$conditionalHandlers = {
...SchemaType.prototype.$conditionalHandlers,
$gt: handleSingle,
$gte: handleSingle,
$lt: handleSingle,
$lte: handleSingle
};

@@ -271,0 +271,0 @@ /*!

@@ -644,3 +644,4 @@ 'use strict';

const $conditionalHandlers = utils.options(SchemaType.prototype.$conditionalHandlers, {
const $conditionalHandlers = {
...SchemaType.prototype.$conditionalHandlers,
$all: handleArray,

@@ -660,3 +661,3 @@ $gt: handleSingle,

$not: handleSingle
});
};

@@ -663,0 +664,0 @@ Object.defineProperty(SchemaString.prototype, '$conditionalHandlers', {

@@ -51,3 +51,3 @@ 'use strict';

this.caster = _createConstructor(schema);
this.caster = _createConstructor(schema, null, options);
this.caster.path = path;

@@ -59,7 +59,2 @@ this.caster.prototype.$basePath = path;

SchemaType.call(this, path, options, 'Embedded');
if (schema._applyDiscriminators != null && !options?._skipApplyDiscriminators) {
for (const disc of schema._applyDiscriminators.keys()) {
this.discriminator(disc, schema._applyDiscriminators.get(disc));
}
}
}

@@ -79,3 +74,3 @@

function _createConstructor(schema, baseClass) {
function _createConstructor(schema, baseClass, options) {
// lazy load

@@ -100,2 +95,3 @@ SubdocumentType || (SubdocumentType = require('../types/subdocument'));

_embedded.prototype.constructor = _embedded;
_embedded.$__required = options?.required;
_embedded.base = schema.base;

@@ -102,0 +98,0 @@ _embedded.schema = schema;

@@ -316,4 +316,4 @@ /*!

SchemaUUID.prototype.$conditionalHandlers =
utils.options(SchemaType.prototype.$conditionalHandlers, {
SchemaUUID.prototype.$conditionalHandlers = {
...SchemaType.prototype.$conditionalHandlers,
$bitsAllClear: handleBitwiseOperator,

@@ -331,3 +331,3 @@ $bitsAnyClear: handleBitwiseOperator,

$nin: handleArray
});
};

@@ -334,0 +334,0 @@ /**

@@ -230,30 +230,3 @@ 'use strict';

/**
* Shallow copies defaults into options.
*
* @param {Object} defaults
* @param {Object} [options]
* @return {Object} the merged object
* @api private
*/
exports.options = function(defaults, options) {
const keys = Object.keys(defaults);
let i = keys.length;
let k;
options = options || {};
while (i--) {
k = keys[i];
if (!(k in options)) {
options[k] = defaults[k];
}
}
return options;
};
/**
* Merges `from` into `to` without overwriting existing properties.

@@ -691,8 +664,2 @@ *

/**
* @see exports.options
*/
exports.object.shallowCopy = exports.options;
const hop = Object.prototype.hasOwnProperty;

@@ -699,0 +666,0 @@

{
"name": "mongoose",
"description": "Mongoose MongoDB ODM",
"version": "8.0.2",
"version": "8.0.3",
"author": "Guillermo Rauch <guillermo@learnboost.com>",

@@ -31,4 +31,4 @@ "keywords": [

"devDependencies": {
"@babel/core": "7.23.2",
"@babel/preset-env": "7.22.20",
"@babel/core": "7.23.5",
"@babel/preset-env": "7.23.5",
"@typescript-eslint/eslint-plugin": "^6.2.1",

@@ -49,11 +49,11 @@ "@typescript-eslint/parser": "^6.2.1",

"dox": "1.0.0",
"eslint": "8.52.0",
"eslint": "8.55.0",
"eslint-plugin-markdown": "^3.0.1",
"eslint-plugin-mocha-no-only": "1.1.1",
"express": "^4.18.1",
"fs-extra": "~11.1.1",
"fs-extra": "~11.2.0",
"highlight.js": "11.8.0",
"lodash.isequal": "4.5.0",
"lodash.isequalwith": "4.4.0",
"markdownlint-cli2": "^0.10.0",
"markdownlint-cli2": "^0.11.0",
"marked": "4.3.0",

@@ -71,3 +71,3 @@ "mkdirp": "^3.0.1",

"tsd": "0.29.0",
"typescript": "5.2.2",
"typescript": "5.3.2",
"uuid": "9.0.1",

@@ -74,0 +74,0 @@ "webpack": "5.89.0"

@@ -265,13 +265,14 @@ import {

IfEquals<PathValueType, Schema.Types.BigInt> extends true ? bigint :
PathValueType extends 'bigint' | 'BigInt' | typeof Schema.Types.BigInt ? bigint :
PathValueType extends 'uuid' | 'UUID' | typeof Schema.Types.UUID ? Buffer :
IfEquals<PathValueType, Schema.Types.UUID> extends true ? Buffer :
PathValueType extends MapConstructor | 'Map' ? Map<string, ResolvePathType<Options['of']>> :
IfEquals<PathValueType, typeof Schema.Types.Map> extends true ? Map<string, ResolvePathType<Options['of']>> :
PathValueType extends ArrayConstructor ? any[] :
PathValueType extends typeof Schema.Types.Mixed ? any:
IfEquals<PathValueType, ObjectConstructor> extends true ? any:
IfEquals<PathValueType, {}> extends true ? any:
PathValueType extends typeof SchemaType ? PathValueType['prototype'] :
PathValueType extends Record<string, any> ? ObtainDocumentType<PathValueType, any, { typeKey: TypeKey }> :
unknown;
IfEquals<PathValueType, BigInt> extends true ? bigint :
PathValueType extends 'bigint' | 'BigInt' | typeof Schema.Types.BigInt | typeof BigInt ? bigint :
PathValueType extends 'uuid' | 'UUID' | typeof Schema.Types.UUID ? Buffer :
IfEquals<PathValueType, Schema.Types.UUID> extends true ? Buffer :
PathValueType extends MapConstructor | 'Map' ? Map<string, ResolvePathType<Options['of']>> :
IfEquals<PathValueType, typeof Schema.Types.Map> extends true ? Map<string, ResolvePathType<Options['of']>> :
PathValueType extends ArrayConstructor ? any[] :
PathValueType extends typeof Schema.Types.Mixed ? any:
IfEquals<PathValueType, ObjectConstructor> extends true ? any:
IfEquals<PathValueType, {}> extends true ? any:
PathValueType extends typeof SchemaType ? PathValueType['prototype'] :
PathValueType extends Record<string, any> ? ObtainDocumentType<PathValueType, any, { typeKey: TypeKey }> :
unknown;

@@ -186,2 +186,6 @@ declare module 'mongoose' {

/* Apply defaults to the given document or POJO. */
applyDefaults(obj: AnyObject): AnyObject;
applyDefaults(obj: TRawDocType): TRawDocType;
/**

@@ -399,2 +403,6 @@ * Sends multiple `insertOne`, `updateOne`, `updateMany`, `replaceOne`,

): Promise<mongodb.InsertManyResult<Require_id<THydratedDocumentType>>>;
insertMany(
doc: Array<TRawDocType>,
options: InsertManyOptions
): Promise<Array<THydratedDocumentType>>;
insertMany<DocContents = TRawDocType>(

@@ -613,7 +621,7 @@ docs: Array<DocContents | TRawDocType>,

findOneAndDelete<ResultDoc = THydratedDocumentType>(
filter?: FilterQuery<TRawDocType>,
options?: QueryOptions<TRawDocType> & { includeResultMetadata: true }
filter: FilterQuery<TRawDocType>,
options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete'>;
findOneAndDelete<ResultDoc = THydratedDocumentType>(
filter?: FilterQuery<TRawDocType>,
filter?: FilterQuery<TRawDocType> | null,
options?: QueryOptions<TRawDocType> | null

@@ -620,0 +628,0 @@ ): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete'>;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc