mongoose 8.24.1 → 8.24.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.umd.js +1 -1
- package/lib/types/subdocument.js +4 -2
- package/package.json +1 -1
- package/types/models.d.ts +5 -5
package/lib/types/subdocument.js
CHANGED
|
@@ -452,7 +452,9 @@ if (util.inspect.custom) {
|
|
|
452
452
|
|
|
453
453
|
/**
|
|
454
454
|
* Override `$toObject()` to handle minimizing the whole path. Should not minimize if schematype-level minimize
|
|
455
|
-
* is set to false re: gh-11247, gh-14058, gh-14151
|
|
455
|
+
* is set to false re: gh-11247, gh-14058, gh-14151. Should not minimize document array elements: an array
|
|
456
|
+
* element cannot be removed without shifting the array, so minimizing it to `undefined` makes the BSON
|
|
457
|
+
* serializer store `null` re: gh-7322.
|
|
456
458
|
*/
|
|
457
459
|
|
|
458
460
|
Subdocument.prototype.$toObject = function $toObject(options, json) {
|
|
@@ -462,7 +464,7 @@ Subdocument.prototype.$toObject = function $toObject(options, json) {
|
|
|
462
464
|
// If minimize is set, then we can minimize out the whole object.
|
|
463
465
|
if (Object.keys(ret).length === 0 && options?._calledWithOptions != null) {
|
|
464
466
|
const minimize = options._calledWithOptions?.minimize ?? this?.$__schemaTypeOptions?.minimize ?? options.minimize;
|
|
465
|
-
if (minimize && !this.constructor.$__required) {
|
|
467
|
+
if (minimize && !this.constructor.$__required && !this.$isDocumentArrayElement) {
|
|
466
468
|
return undefined;
|
|
467
469
|
}
|
|
468
470
|
}
|
package/package.json
CHANGED
package/types/models.d.ts
CHANGED
|
@@ -660,11 +660,11 @@ declare module 'mongoose' {
|
|
|
660
660
|
*/
|
|
661
661
|
useConnection(connection: Connection): this;
|
|
662
662
|
|
|
663
|
-
/** Casts and validates the given object against this model's schema, passing the given `context` to custom validators. */
|
|
664
|
-
validate(): Promise<
|
|
665
|
-
validate(obj: any): Promise<
|
|
666
|
-
validate(obj: any, pathsOrOptions: PathsToValidate): Promise<
|
|
667
|
-
validate(obj: any, pathsOrOptions: { pathsToSkip?: pathsToSkip }): Promise<
|
|
663
|
+
/** Casts and validates the given object against this model's schema, returning the casted-and-validated copy of `obj`, passing the given `context` to custom validators. */
|
|
664
|
+
validate(): Promise<TRawDocType>;
|
|
665
|
+
validate(obj: any): Promise<TRawDocType>;
|
|
666
|
+
validate(obj: any, pathsOrOptions: PathsToValidate): Promise<TRawDocType>;
|
|
667
|
+
validate(obj: any, pathsOrOptions: { pathsToSkip?: pathsToSkip }): Promise<TRawDocType>;
|
|
668
668
|
|
|
669
669
|
/** Watches the underlying collection for changes using [MongoDB change streams](https://www.mongodb.com/docs/manual/changeStreams/). */
|
|
670
670
|
watch<ResultType extends mongodb.Document = any, ChangeType extends mongodb.ChangeStreamDocument = any>(pipeline?: Array<Record<string, unknown>>, options?: mongodb.ChangeStreamOptions & { hydrate?: boolean }): mongodb.ChangeStream<ResultType, ChangeType>;
|