Skip to content

Commit

Permalink
Merge pull request #14295 from Automattic/IslandRhythms/gh-14279
Browse files Browse the repository at this point in the history
add type for createCollections
  • Loading branch information
vkarpov15 committed Jan 25, 2024
2 parents 6b3f998 + 56f0515 commit 33c624e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/types/connection.test.ts
Expand Up @@ -20,6 +20,10 @@ conn.readyState === 99;

expectError(conn.readyState = 0);

expectType<Promise<Record<string, Error | mongodb.Collection<any>>>>(
conn.createCollections()
);

expectType<Connection>(new Connection());
expectType<Promise<Connection>>(new Connection().asPromise());

Expand Down
5 changes: 5 additions & 0 deletions types/connection.d.ts
Expand Up @@ -81,6 +81,11 @@ declare module 'mongoose' {
*/
createCollection<T extends AnyObject = AnyObject>(name: string, options?: mongodb.CreateCollectionOptions): Promise<mongodb.Collection<T>>;

/**
* https://mongoosejs.com/docs/api/connection.html#Connection.prototype.createCollections()
*/
createCollections(continueOnError?: boolean): Promise<Record<string, Error | mongodb.Collection<any>>>;

/**
* Removes the model named `name` from this connection, if it exists. You can
* use this function to clean up any models you created in your tests to
Expand Down

0 comments on commit 33c624e

Please sign in to comment.