Socket
Socket
Sign inDemoInstall

mongoose

Package Overview
Dependencies
Maintainers
4
Versions
884
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose - npm Package Compare versions

Comparing version 8.2.0 to 8.2.1

24

lib/connection.js

@@ -833,2 +833,26 @@ 'use strict';

/*!
* Treat `on('error')` handlers as handling the initialConnection promise
* to avoid uncaught exceptions when using `on('error')`. See gh-14377.
*/
Connection.prototype.on = function on(event, callback) {
if (event === 'error' && this.$initialConnection) {
this.$initialConnection.catch(() => {});
}
return EventEmitter.prototype.on.call(this, event, callback);
};
/*!
* Treat `once('error')` handlers as handling the initialConnection promise
* to avoid uncaught exceptions when using `on('error')`. See gh-14377.
*/
Connection.prototype.once = function on(event, callback) {
if (event === 'error' && this.$initialConnection) {
this.$initialConnection.catch(() => {});
}
return EventEmitter.prototype.once.call(this, event, callback);
};
/*!
* ignore

@@ -835,0 +859,0 @@ */

21

lib/helpers/clone.js

@@ -39,6 +39,19 @@ 'use strict';

if (isMongooseObject(obj)) {
// Single nested subdocs should apply getters later in `applyGetters()`
// when calling `toObject()`. See gh-7442, gh-8295
if (options && options._skipSingleNestedGetters && obj.$isSingleNested) {
options = Object.assign({}, options, { getters: false });
if (options) {
// Single nested subdocs should apply getters later in `applyGetters()`
// when calling `toObject()`. See gh-7442, gh-8295
if (options._skipSingleNestedGetters && obj.$isSingleNested) {
options = Object.assign({}, options, { getters: false });
}
if (options.retainDocuments && obj.$__ != null) {
const clonedDoc = obj.$clone();
if (obj.__index != null) {
clonedDoc.__index = obj.__index;
}
if (obj.__parentArray != null) {
clonedDoc.__parentArray = obj.__parentArray;
}
clonedDoc.$__parent = obj.$__parent;
return clonedDoc;
}
}

@@ -45,0 +58,0 @@ const isSingleNested = obj.$isSingleNested;

9

lib/helpers/discriminator/applyEmbeddedDiscriminators.js

@@ -22,7 +22,6 @@ 'use strict';

}
for (const disc of schemaType.schema._applyDiscriminators.keys()) {
schemaType.discriminator(
disc,
schemaType.schema._applyDiscriminators.get(disc)
);
for (const discriminatorKey of schemaType.schema._applyDiscriminators.keys()) {
const discriminatorSchema = schemaType.schema._applyDiscriminators.get(discriminatorKey);
applyEmbeddedDiscriminators(discriminatorSchema, seen);
schemaType.discriminator(discriminatorKey, discriminatorSchema);
}

@@ -29,0 +28,0 @@ schemaType._appliedDiscriminators = true;

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

}
// Don't apply default write concern to operations in transactions,
// because setting write concern on an operation in a transaction is an error
// See: https://www.mongodb.com/docs/manual/reference/write-concern/
if (options && options.session && options.session.transaction) {
return;
}
const writeConcern = get(schema, 'options.writeConcern', {});

@@ -11,0 +17,0 @@ if (Object.keys(writeConcern).length != 0) {

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

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

"devDependencies": {
"@babel/core": "7.23.9",
"@babel/preset-env": "7.23.9",
"@babel/core": "7.24.0",
"@babel/preset-env": "7.24.0",
"@typescript-eslint/eslint-plugin": "^6.2.1",

@@ -47,5 +47,5 @@ "@typescript-eslint/parser": "^6.2.1",

"crypto-browserify": "3.12.0",
"dotenv": "16.4.1",
"dotenv": "16.4.5",
"dox": "1.0.0",
"eslint": "8.56.0",
"eslint": "8.57.0",
"eslint-plugin-markdown": "^3.0.1",

@@ -61,3 +61,3 @@ "eslint-plugin-mocha-no-only": "1.1.1",

"mkdirp": "^3.0.1",
"mocha": "10.2.0",
"mocha": "10.3.0",
"moment": "2.x",

@@ -71,6 +71,6 @@ "mongodb-memory-server": "8.15.1",

"stream-browserify": "3.0.0",
"tsd": "0.30.4",
"tsd": "0.30.7",
"typescript": "5.3.3",
"uuid": "9.0.1",
"webpack": "5.90.1"
"webpack": "5.90.3"
},

@@ -77,0 +77,0 @@ "directories": {

@@ -231,3 +231,3 @@ declare module 'mongoose' {

filter?: FilterQuery<TRawDocType>,
options?: (mongodb.CountOptions & Omit<MongooseQueryOptions<TRawDocType>, 'lean' | 'timestamps'>) | null
options?: (mongodb.CountOptions & MongooseBaseQueryOptions<TRawDocType>) | null
): QueryWithHelpers<

@@ -270,3 +270,3 @@ number,

filter?: FilterQuery<TRawDocType>,
options?: (mongodb.DeleteOptions & Omit<MongooseQueryOptions<TRawDocType>, 'lean' | 'timestamps'>) | null
options?: (mongodb.DeleteOptions & MongooseBaseQueryOptions<TRawDocType>) | null
): QueryWithHelpers<

@@ -296,3 +296,3 @@ mongodb.DeleteResult,

filter?: FilterQuery<TRawDocType>,
options?: (mongodb.DeleteOptions & Omit<MongooseQueryOptions<TRawDocType>, 'lean' | 'timestamps'>) | null
options?: (mongodb.DeleteOptions & MongooseBaseQueryOptions<TRawDocType>) | null
): QueryWithHelpers<

@@ -749,3 +749,3 @@ mongodb.DeleteResult,

update?: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,
options?: (mongodb.UpdateOptions & Omit<MongooseQueryOptions<TRawDocType>, 'lean'>) | null
options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions<TRawDocType>) | null
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType, 'updateMany'>;

@@ -757,3 +757,3 @@

update?: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,
options?: (mongodb.UpdateOptions & Omit<MongooseQueryOptions<TRawDocType>, 'lean'>) | null
options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions<TRawDocType>) | null
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType, 'updateOne'>;

@@ -760,0 +760,0 @@

@@ -20,21 +20,29 @@ declare module 'mongoose' {

type MongooseQueryOptions<DocType = unknown> = Pick<
QueryOptions<DocType>,
'context' |
'lean' |
'multipleCastError' |
'overwriteDiscriminatorKey' |
'populate' |
'runValidators' |
'sanitizeProjection' |
'sanitizeFilter' |
'setDefaultsOnInsert' |
'strict' |
'strictQuery' |
'timestamps' |
'translateAliases'
> & {
type MongooseBaseQueryOptionKeys =
| 'context'
| 'multipleCastError'
| 'overwriteDiscriminatorKey'
| 'populate'
| 'runValidators'
| 'sanitizeProjection'
| 'sanitizeFilter'
| 'setDefaultsOnInsert'
| 'strict'
| 'strictQuery'
| 'translateAliases';
type MongooseQueryOptions<
DocType = unknown,
Keys extends keyof QueryOptions<DocType> = MongooseBaseQueryOptionKeys | 'timestamps' | 'lean'
> = Pick<QueryOptions<DocType>, Keys> & {
[other: string]: any;
};
type MongooseBaseQueryOptions<DocType = unknown> = MongooseQueryOptions<DocType, MongooseBaseQueryOptionKeys>;
type MongooseUpdateQueryOptions<DocType = unknown> = MongooseQueryOptions<
DocType,
MongooseBaseQueryOptionKeys | 'timestamps'
>;
type ProjectionFields<DocType> = { [Key in keyof DocType]?: any } & Record<string, any>;

@@ -212,3 +220,3 @@

*/
[Symbol.asyncIterator](): AsyncIterableIterator<DocType>;
[Symbol.asyncIterator](): AsyncIterableIterator<Unpacked<ResultType>>;

@@ -291,3 +299,3 @@ /** Executes the query */

*/
cursor(options?: QueryOptions<DocType>): Cursor<DocType, QueryOptions<DocType>>;
cursor(options?: QueryOptions<DocType>): Cursor<Unpacked<ResultType>, QueryOptions<DocType>>;

@@ -653,3 +661,3 @@ /**

select<RawDocTypeOverride extends { [P in keyof RawDocType]?: any } = {}>(
arg: string | string[] | Record<string, number | boolean | object>
arg: string | string[] | Record<string, number | boolean | string | object>
): QueryWithHelpers<

@@ -656,0 +664,0 @@ IfEquals<

@@ -5,2 +5,13 @@ declare module 'mongoose' {

/**
* @summary Removes keys from a type
* @description It helps to exclude keys from a type
* @param {T} T A generic type to be checked.
* @param {K} K Keys from T that are to be excluded from the generic type
* @returns T with the keys in K excluded
*/
type ExcludeKeys<T, K extends keyof T> = {
[P in keyof T as P extends K ? never : P]: T[P];
};
type Unpacked<T> = T extends (infer U)[] ?

@@ -7,0 +18,0 @@ U :

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc