mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
fix(mongoose): Connection's aren't truly thenable
This commit is contained in:
Vendored
+5
-5
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Mongoose 5.0.1
|
||||
// Type definitions for Mongoose 5.0.2
|
||||
// Project: http://mongoosejs.com/
|
||||
// Definitions by: horiuchi <https://github.com/horiuchi>
|
||||
// sindrenm <https://github.com/sindrenm>
|
||||
@@ -97,7 +97,10 @@ declare module "mongoose" {
|
||||
export function createConnection(): Connection;
|
||||
export function createConnection(uri: string,
|
||||
options?: ConnectionOptions
|
||||
): Connection;
|
||||
): Connection & {
|
||||
then: Promise<Connection>["then"];
|
||||
catch: Promise<Connection>["catch"];
|
||||
};
|
||||
|
||||
/**
|
||||
* Disconnects all connections.
|
||||
@@ -403,9 +406,6 @@ declare module "mongoose" {
|
||||
|
||||
/** Expose the possible connection states. */
|
||||
static STATES: any;
|
||||
|
||||
then: Promise<Connection>["then"];
|
||||
catch: Promise<Connection>["catch"];
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -131,6 +131,13 @@ mongoose.Connection.STATES.hasOwnProperty('');
|
||||
conn1.on('data', cb);
|
||||
conn1.addListener('close', cb);
|
||||
|
||||
// The connection returned by useDb is *not* thenable.
|
||||
// From https://github.com/DefinitelyTyped/DefinitelyTyped/pull/26057#issuecomment-396150819
|
||||
const getDB = async (tenant: string)=> {
|
||||
return conn1.useDb(tenant);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* section error/validation.js
|
||||
* http://mongoosejs.com/docs/api.html#error-validation-js
|
||||
|
||||
Reference in New Issue
Block a user