Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoose

Package Overview
Dependencies
Maintainers
4
Versions
890
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.7.1 to 8.7.2

16

lib/helpers/document/cleanModifiedSubpaths.js

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

if (doc.$isSubdocument) {
const owner = doc.ownerDocument();
const fullPath = doc.$__fullPath(modifiedPath);
owner.$__.activePaths.clearPath(fullPath);
cleanParent(doc, modifiedPath);
}

@@ -37,1 +35,13 @@ }

};
function cleanParent(doc, path, seen = new Set()) {
if (seen.has(doc)) {
throw new Error('Infinite subdocument loop: subdoc with _id ' + doc._id + ' is a parent of itself');
}
const parent = doc.$parent();
const newPath = doc.$__pathRelativeToParent(void 0, false) + '.' + path;
parent.$__.activePaths.clearPath(newPath);
if (parent.$isSubdocument) {
cleanParent(parent, newPath, seen);
}
}

24

lib/helpers/populate/getModelsMapForPopulate.js

@@ -481,5 +481,6 @@ 'use strict';

let k = modelNames.length;
const flatModelNames = utils.array.flatten(modelNames);
let k = flatModelNames.length;
while (k--) {
let modelName = modelNames[k];
let modelName = flatModelNames[k];
if (modelName == null) {

@@ -507,7 +508,6 @@ continue;

let ids = ret;
const flat = Array.isArray(ret) ? utils.array.flatten(ret) : [];
const modelNamesForRefPath = data.modelNamesInOrder ? data.modelNamesInOrder : modelNames;
if (data.isRefPath && Array.isArray(ret) && flat.length === modelNamesForRefPath.length) {
ids = flat.filter((val, i) => modelNamesForRefPath[i] === modelName);
if (data.isRefPath && Array.isArray(ret) && ret.length === modelNamesForRefPath.length) {
ids = matchIdsToRefPaths(ret, modelNamesForRefPath, modelName);
}

@@ -574,2 +574,16 @@

function matchIdsToRefPaths(ids, refPaths, refPathToFind) {
if (!Array.isArray(refPaths)) {
return refPaths === refPathToFind
? Array.isArray(ids)
? utils.array.flatten(ids)
: [ids]
: [];
}
if (Array.isArray(ids) && Array.isArray(refPaths)) {
return ids.flatMap((id, index) => matchIdsToRefPaths(id, refPaths[index], refPathToFind));
}
return [];
}
/*!

@@ -576,0 +590,0 @@ * ignore

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

modelNames = utils.array.flatten(modelNames);
return modelNames;
};
{
"name": "mongoose",
"description": "Mongoose MongoDB ODM",
"version": "8.7.1",
"version": "8.7.2",
"author": "Guillermo Rauch <guillermo@learnboost.com>",

@@ -95,3 +95,3 @@ "keywords": [

"lint-ts": "eslint . --ext .ts",
"lint-md": "markdownlint-cli2 \"**/*.md\"",
"lint-md": "markdownlint-cli2 \"**/*.md\" \"#node_modules\" \"#benchmarks\"",
"build-browser": "(rm ./dist/* || true) && node ./scripts/build-browser.js",

@@ -98,0 +98,0 @@ "prepublishOnly": "npm run build-browser",

@@ -709,2 +709,14 @@ /// <reference path="./aggregate.d.ts" />

export type BufferToBinary<T> = T extends TreatAsPrimitives ? T : T extends Record<string, any> ? {
[K in keyof T]: T[K] extends Buffer
? mongodb.Binary
: T[K] extends (Buffer | null | undefined)
? mongodb.Binary | null | undefined
: T[K] extends Types.DocumentArray<infer ItemType>
? Types.DocumentArray<BufferToBinary<ItemType>>
: T[K] extends Types.Subdocument<unknown, unknown, infer SubdocType>
? HydratedSingleSubdocument<SubdocType>
: BufferToBinary<T[K]>;
} : T;
/**

@@ -720,3 +732,3 @@ * Separate type is needed for properties of union type (for example, Types.DocumentArray | undefined) to apply conditional check to each member of it

export type actualPrimitives = string | boolean | number | bigint | symbol | null | undefined;
export type TreatAsPrimitives = actualPrimitives | NativeDate | RegExp | symbol | Error | BigInt | Types.ObjectId | Buffer | Function;
export type TreatAsPrimitives = actualPrimitives | NativeDate | RegExp | symbol | Error | BigInt | Types.ObjectId | Buffer | Function | mongodb.Binary;

@@ -723,0 +735,0 @@ export type SchemaDefinitionType<T> = T extends Document ? Omit<T, Exclude<keyof Document, '_id' | 'id' | '__v'>> : T;

@@ -186,4 +186,12 @@ import {

type ObtainDocumentPathType<PathValueType, TypeKey extends string = DefaultTypeKey> = ResolvePathType<
PathValueType extends PathWithTypePropertyBaseType<TypeKey> ? PathValueType[TypeKey] : PathValueType,
PathValueType extends PathWithTypePropertyBaseType<TypeKey> ? Omit<PathValueType, TypeKey> : {},
PathValueType extends PathWithTypePropertyBaseType<TypeKey>
? PathValueType[TypeKey] extends PathWithTypePropertyBaseType<TypeKey>
? PathValueType
: PathValueType[TypeKey]
: PathValueType,
PathValueType extends PathWithTypePropertyBaseType<TypeKey>
? PathValueType[TypeKey] extends PathWithTypePropertyBaseType<TypeKey>
? {}
: Omit<PathValueType, TypeKey>
: {},
TypeKey,

@@ -190,0 +198,0 @@ TypeHint<PathValueType>

@@ -75,2 +75,4 @@ declare module 'mongoose' {

type UpdateWriteOpResult = mongodb.UpdateResult;
type UpdateResult = mongodb.UpdateResult;
type DeleteResult = mongodb.DeleteResult;

@@ -77,0 +79,0 @@ interface MapReduceOptions<T, K, R> {

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

type GetLeanResultType<RawDocType, ResultType, QueryOp> = QueryOp extends QueryOpThatReturnsDocument
? (ResultType extends any[] ? Require_id<FlattenMaps<RawDocType>>[] : Require_id<FlattenMaps<RawDocType>>)
? (ResultType extends any[] ? Require_id<BufferToBinary<FlattenMaps<RawDocType>>>[] : Require_id<BufferToBinary<FlattenMaps<RawDocType>>>)
: ResultType;

@@ -217,0 +217,0 @@

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