Skip to content

Commit

Permalink
Merge pull request #15127 from Automattic/vkarpov15/syncindexes-ts
Browse files Browse the repository at this point in the history
types: add cleanIndexes() to IndexManager interface
  • Loading branch information
vkarpov15 authored Dec 26, 2024
2 parents 610a146 + ae001e7 commit 4081e5c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3692,7 +3692,7 @@ Model.castObject = function castObject(obj, options) {
}

if (schemaType.$isMongooseDocumentArray) {
const castNonArraysOption = schemaType.options?.castNonArrays ??schemaType.constructor.options.castNonArrays;
const castNonArraysOption = schemaType.options?.castNonArrays ?? schemaType.constructor.options.castNonArrays;
if (!Array.isArray(val)) {
if (!castNonArraysOption) {
if (!options.ignoreCastErrors) {
Expand Down
3 changes: 3 additions & 0 deletions types/indexes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ declare module 'mongoose' {
function syncIndexes(options?: SyncIndexesOptions): Promise<ConnectionSyncIndexesResult>;

interface IndexManager {
/* Deletes all indexes that aren't defined in this model's schema. Used by `syncIndexes()`. Returns list of dropped index names. */
cleanIndexes(options?: { toDrop?: string[], hideIndexes?: boolean }): Promise<string[]>;

/**
* Similar to `ensureIndexes()`, except for it uses the [`createIndex`](https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html#createIndex)
* function.
Expand Down

0 comments on commit 4081e5c

Please sign in to comment.