New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mongoose

Package Overview
Dependencies
Maintainers
4
Versions
919
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.10.2 to 8.11.0

lib/types/double.js

16

lib/cast/bigint.js
'use strict';
const assert = require('assert');
const { Long } = require('bson');

@@ -16,2 +15,6 @@

const MAX_BIGINT = 9223372036854775807n;
const MIN_BIGINT = -9223372036854775808n;
const ERROR_MESSAGE = `Mongoose only supports BigInts between ${MIN_BIGINT} and ${MAX_BIGINT} because MongoDB does not support arbitrary precision integers`;
module.exports = function castBigInt(val) {

@@ -25,2 +28,5 @@ if (val == null) {

if (typeof val === 'bigint') {
if (val > MAX_BIGINT || val < MIN_BIGINT) {
throw new Error(ERROR_MESSAGE);
}
return val;

@@ -34,6 +40,10 @@ }

if (typeof val === 'string' || typeof val === 'number') {
return BigInt(val);
val = BigInt(val);
if (val > MAX_BIGINT || val < MIN_BIGINT) {
throw new Error(ERROR_MESSAGE);
}
return val;
}
assert.ok(false);
throw new Error(`Cannot convert value to BigInt: "${val}"`);
};

@@ -15,2 +15,3 @@

exports.DocumentArray = require('./documentArray');
exports.Double = require('./double');
exports.Decimal128 = require('./decimal128');

@@ -17,0 +18,0 @@ exports.ObjectId = require('./objectid');

10

lib/utils.js

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

if (typeof obj.path !== 'string') {
throw new TypeError('utils.populate: invalid path. Expected string. Got typeof `' + typeof path + '`');
if (typeof obj.path !== 'string' && !(Array.isArray(obj.path) && obj.path.every(el => typeof el === 'string'))) {
throw new TypeError('utils.populate: invalid path. Expected string or array of strings. Got typeof `' + typeof path + '`');
}

@@ -604,3 +604,7 @@

const ret = [];
const paths = oneSpaceRE.test(obj.path) ? obj.path.split(manySpaceRE) : [obj.path];
const paths = oneSpaceRE.test(obj.path)
? obj.path.split(manySpaceRE)
: Array.isArray(obj.path)
? obj.path
: [obj.path];
if (obj.options != null) {

@@ -607,0 +611,0 @@ obj.options = clone(obj.options);

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

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

@@ -207,10 +207,16 @@ /// <reference path="./aggregate.d.ts" />

export interface ToObjectOptions<THydratedDocumentType = HydratedDocument<unknown>> {
/** if `options.virtuals = true`, you can set `options.aliases = false` to skip applying aliases. This option is a no-op if `options.virtuals = false`. */
aliases?: boolean;
/** if true, replace any conventionally populated paths with the original id in the output. Has no affect on virtual populated paths. */
depopulate?: boolean;
/** if true, convert Maps to POJOs. Useful if you want to `JSON.stringify()` the result of `toObject()`. */
flattenMaps?: boolean;
/** if true, convert any ObjectIds in the result to 24 character hex strings. */
flattenObjectIds?: boolean;
/** apply all getters (path and virtual getters) */
getters?: boolean;
/** apply virtual getters (can override getters option) */
virtuals?: boolean | string[];
/** if `options.virtuals = true`, you can set `options.aliases = false` to skip applying aliases. This option is a no-op if `options.virtuals = false`. */
aliases?: boolean;
/** remove empty objects (defaults to true) */
minimize?: boolean;
/** If true, the resulting object will only have fields that are defined in the document's schema. By default, `toJSON()` & `toObject()` returns all fields in the underlying document from MongoDB, including ones that are not listed in the schema. */
schemaFieldsOnly?: boolean;
/** if set, mongoose will call this function to allow you to transform the returned object */

@@ -222,12 +228,8 @@ transform?: boolean | ((

) => any);
/** if true, replace any conventionally populated paths with the original id in the output. Has no affect on virtual populated paths. */
depopulate?: boolean;
/** If true, omits fields that are excluded in this document's projection. Unless you specified a projection, this will omit any field that has `select: false` in the schema. */
useProjection?: boolean;
/** if false, exclude the version key (`__v` by default) from the output */
versionKey?: boolean;
/** if true, convert Maps to POJOs. Useful if you want to `JSON.stringify()` the result of `toObject()`. */
flattenMaps?: boolean;
/** if true, convert any ObjectIds in the result to 24 character hex strings. */
flattenObjectIds?: boolean;
/** If true, omits fields that are excluded in this document's projection. Unless you specified a projection, this will omit any field that has `select: false` in the schema. */
useProjection?: boolean;
/** apply virtual getters (can override getters option) */
virtuals?: boolean | string[];
}

@@ -234,0 +236,0 @@

@@ -315,12 +315,13 @@ import {

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,
PathValueType extends 'double' | 'Double' | typeof Schema.Types.Double ? Types.Double :
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,
TypeHint>;

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

options: MongooseBulkWriteOptions & { ordered: false }
): Promise<mongodb.BulkWriteResult & { mongoose?: { validationErrors: Error[], results: Array<Error | null> } }>;
): Promise<mongodb.BulkWriteResult & { mongoose?: { validationErrors: Error[], results: Array<Error | mongodb.WriteError | null> } }>;
bulkWrite<DocContents = TRawDocType>(

@@ -314,0 +314,0 @@ writes: Array<AnyBulkWriteOperation<DocContents extends Document ? any : (DocContents extends {} ? DocContents : any)>>,

@@ -42,2 +42,8 @@ declare module 'mongoose' {

forceRepopulate?: boolean;
/**
* Set to `true` to execute any populate queries one at a time, as opposed to in parallel.
* We recommend setting this option to `true` if using transactions, especially if also populating multiple paths or paths with multiple models.
* MongoDB server does **not** support multiple operations in parallel on a single transaction.
*/
ordered?: boolean;
}

@@ -44,0 +50,0 @@

@@ -107,3 +107,5 @@

class UUID extends bson.UUID {}
class Double extends bson.Double {}
}
}

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