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.1.3 to 8.2.0

lib/constants.js

4

lib/aggregate.js

@@ -1022,4 +1022,4 @@ 'use strict';

applyGlobalMaxTimeMS(this.options, model);
applyGlobalDiskUse(this.options, model);
applyGlobalMaxTimeMS(this.options, model.db.options, model.base.options);
applyGlobalDiskUse(this.options, model.db.options, model.base.options);

@@ -1026,0 +1026,0 @@ if (this.options && this.options.cursor) {

@@ -447,2 +447,24 @@ 'use strict';

/**
* A convenience wrapper for `connection.client.withSession()`.
*
* #### Example:
*
* await conn.withSession(async session => {
* const doc = await TestModel.findOne().session(session);
* });
*
* @method withSession
* @param {Function} executor called with 1 argument: a `ClientSession` instance
* @return {Promise} resolves to the return value of the executor function
* @api public
*/
Connection.prototype.withSession = async function withSession(executor) {
if (arguments.length === 0) {
throw new Error('Please provide an executor function');
}
return await this.client.withSession(executor);
};
/**
* _Requires MongoDB >= 3.6.0._ Starts a [MongoDB session](https://www.mongodb.com/docs/manual/release-notes/3.6/#client-sessions)

@@ -449,0 +471,0 @@ * for benefits like causal consistency, [retryable writes](https://www.mongodb.com/docs/manual/core/retryable-writes/),

'use strict';
const middlewareFunctions = require('../query/applyQueryMiddleware').middlewareFunctions;
const middlewareFunctions = require('../../constants').queryMiddlewareFunctions;
const promiseOrCallback = require('../promiseOrCallback');

@@ -5,0 +5,0 @@

@@ -5,8 +5,8 @@ 'use strict';

function applyGlobalMaxTimeMS(options, model) {
applyGlobalOption(options, model, 'maxTimeMS');
function applyGlobalMaxTimeMS(options, connectionOptions, baseOptions) {
applyGlobalOption(options, connectionOptions, baseOptions, 'maxTimeMS');
}
function applyGlobalDiskUse(options, model) {
applyGlobalOption(options, model, 'allowDiskUse');
function applyGlobalDiskUse(options, connectionOptions, baseOptions) {
applyGlobalOption(options, connectionOptions, baseOptions, 'allowDiskUse');
}

@@ -20,3 +20,3 @@

function applyGlobalOption(options, model, optionName) {
function applyGlobalOption(options, connectionOptions, baseOptions, optionName) {
if (utils.hasUserDefinedProperty(options, optionName)) {

@@ -26,7 +26,7 @@ return;

if (utils.hasUserDefinedProperty(model.db.options, optionName)) {
options[optionName] = model.db.options[optionName];
} else if (utils.hasUserDefinedProperty(model.base.options, optionName)) {
options[optionName] = model.base.options[optionName];
if (utils.hasUserDefinedProperty(connectionOptions, optionName)) {
options[optionName] = connectionOptions[optionName];
} else if (utils.hasUserDefinedProperty(baseOptions, optionName)) {
options[optionName] = baseOptions[optionName];
}
}

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

module.exports = function castFilterPath(query, schematype, val) {
const ctx = query;
module.exports = function castFilterPath(ctx, schematype, val) {
const any$conditionals = Object.keys(val).some(isOperator);

@@ -9,0 +8,0 @@

'use strict';
module.exports = Object.freeze([
// Read
'countDocuments',
'distinct',
'estimatedDocumentCount',
'find',
'findOne',
// Update
'findOneAndReplace',
'findOneAndUpdate',
'replaceOne',
'updateMany',
'updateOne',
// Delete
'deleteMany',
'deleteOne',
'findOneAndDelete'
]);
module.exports = require('../../constants').queryMiddlewareFunctions;
{
"name": "mongoose",
"description": "Mongoose MongoDB ODM",
"version": "8.1.3",
"version": "8.2.0",
"author": "Guillermo Rauch <guillermo@learnboost.com>",

@@ -6,0 +6,0 @@ "keywords": [

@@ -243,4 +243,6 @@ declare module 'mongoose' {

watch<ResultType extends mongodb.Document = any>(pipeline?: Array<any>, options?: mongodb.ChangeStreamOptions): mongodb.ChangeStream<ResultType>;
withSession<T = any>(executor: (session: ClientSession) => Promise<T>): T;
}
}

@@ -376,4 +376,4 @@ /// <reference path="./aggregate.d.ts" />

post<T extends Aggregate<any>>(method: 'aggregate' | RegExp, options: SchemaPostOptions, fn: ErrorHandlingMiddlewareFunction<T, Array<any>>): this;
post<T = TModelType>(method: 'insertMany' | RegExp, fn: ErrorHandlingMiddlewareFunction<T>): this;
post<T = TModelType>(method: 'insertMany' | RegExp, options: SchemaPostOptions, fn: ErrorHandlingMiddlewareFunction<T>): this;
post<T = TModelType>(method: 'bulkWrite' | 'createCollection' | 'insertMany' | RegExp, fn: ErrorHandlingMiddlewareFunction<T>): this;
post<T = TModelType>(method: 'bulkWrite' | 'createCollection' | 'insertMany' | RegExp, options: SchemaPostOptions, fn: ErrorHandlingMiddlewareFunction<T>): this;

@@ -433,2 +433,40 @@ /** Defines a pre hook for the model. */

): this;
/* method bulkWrite */
pre<T = TModelType>(
method: 'bulkWrite' | RegExp,
fn: (
this: T,
next: (err?: CallbackError) => void,
ops: Array<mongodb.AnyBulkWriteOperation<any> & MongooseBulkWritePerWriteOptions>,
options?: mongodb.BulkWriteOptions & MongooseBulkWriteOptions
) => void | Promise<void>
): this;
pre<T = TModelType>(
method: 'bulkWrite' | RegExp,
options: SchemaPreOptions,
fn: (
this: T,
next: (err?: CallbackError) => void,
ops: Array<mongodb.AnyBulkWriteOperation<any> & MongooseBulkWritePerWriteOptions>,
options?: mongodb.BulkWriteOptions & MongooseBulkWriteOptions
) => void | Promise<void>
): this;
/* method createCollection */
pre<T = TModelType>(
method: 'createCollection' | RegExp,
fn: (
this: T,
next: (err?: CallbackError) => void,
options?: mongodb.CreateCollectionOptions & Pick<SchemaOptions, 'expires'>
) => void | Promise<void>
): this;
pre<T = TModelType>(
method: 'createCollection' | RegExp,
options: SchemaPreOptions,
fn: (
this: T,
next: (err?: CallbackError) => void,
options?: mongodb.CreateCollectionOptions & Pick<SchemaOptions, 'expires'>
) => void | Promise<void>
): this;

@@ -435,0 +473,0 @@ /** Object of currently defined query helpers on this schema. */

@@ -40,2 +40,7 @@ declare module 'mongoose' {

interface HydrateOptions {
setters?: boolean;
hydratedPopulatedDocs?: boolean;
}
interface InsertManyOptions extends

@@ -375,3 +380,3 @@ PopulateOption,

*/
hydrate(obj: any, projection?: AnyObject, options?: { setters?: boolean }): THydratedDocumentType;
hydrate(obj: any, projection?: AnyObject, options?: HydrateOptions): THydratedDocumentType;

@@ -733,2 +738,5 @@ /**

/** Apply changes made to this model's schema after this model was compiled. */
recompileSchema(): void;
/** Schema the model uses. */

@@ -735,0 +743,0 @@ schema: Schema<TRawDocType>;

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc