Skip to content

Commit 4081e5c

Browse files
authored
Merge pull request Automattic#15127 from Automattic/vkarpov15/syncindexes-ts
types: add cleanIndexes() to IndexManager interface
2 parents 610a146 + ae001e7 commit 4081e5c

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3692,7 +3692,7 @@ Model.castObject = function castObject(obj, options) {
36923692
}
36933693

36943694
if (schemaType.$isMongooseDocumentArray) {
3695-
const castNonArraysOption = schemaType.options?.castNonArrays ??schemaType.constructor.options.castNonArrays;
3695+
const castNonArraysOption = schemaType.options?.castNonArrays ?? schemaType.constructor.options.castNonArrays;
36963696
if (!Array.isArray(val)) {
36973697
if (!castNonArraysOption) {
36983698
if (!options.ignoreCastErrors) {

types/indexes.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ declare module 'mongoose' {
1010
function syncIndexes(options?: SyncIndexesOptions): Promise<ConnectionSyncIndexesResult>;
1111

1212
interface IndexManager {
13+
/* Deletes all indexes that aren't defined in this model's schema. Used by `syncIndexes()`. Returns list of dropped index names. */
14+
cleanIndexes(options?: { toDrop?: string[], hideIndexes?: boolean }): Promise<string[]>;
15+
1316
/**
1417
* Similar to `ensureIndexes()`, except for it uses the [`createIndex`](https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html#createIndex)
1518
* function.

0 commit comments

Comments
 (0)