mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Update definitions for connect-mongo 3.0 (#39278)
This commit is contained in:
parent
8e851d8433
commit
f35ee70d16
@ -11,42 +11,47 @@ var MongoStore = connectMongo(session);
|
||||
|
||||
/// Use MongoStore
|
||||
|
||||
var url = 'mongodb://localhost/test';
|
||||
|
||||
// MongoUrlOptions
|
||||
app.use(session({
|
||||
secret: 'secret',
|
||||
store: new MongoStore({url: 'mongodb://localhost/test'})
|
||||
store: new MongoStore({url})
|
||||
}));
|
||||
|
||||
|
||||
app.use(session({
|
||||
secret: 'secret',
|
||||
store: new MongoStore({
|
||||
url: 'mongodb://localhost/test',
|
||||
url,
|
||||
collection: "test-sessions",
|
||||
ttl: 30 * 24 * 60 * 60 // = 30 days
|
||||
})
|
||||
}));
|
||||
|
||||
// MongooseConnectionOptions
|
||||
mongoose.connect('mongodb://localhost/test')
|
||||
mongoose.connect(url)
|
||||
app.use(session({
|
||||
secret: 'secret',
|
||||
store: new MongoStore({mongooseConnection: mongoose.connection})
|
||||
}));
|
||||
|
||||
// NativeMongoOptions
|
||||
var Db = mongodb.Db
|
||||
var Server = mongodb.Server
|
||||
var mongoDb = new Db('test', new Server('localhost', 27017));
|
||||
app.use(session({
|
||||
secret: 'secret',
|
||||
store: new MongoStore({db: mongoDb})
|
||||
}));
|
||||
var MongoClient = mongodb.MongoClient;
|
||||
MongoClient.connect(url, {
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true,
|
||||
}).then(client => {
|
||||
app.use(session({
|
||||
secret: 'secret',
|
||||
store: new MongoStore({ client })
|
||||
}));
|
||||
});
|
||||
|
||||
// NativeMongoPromiseOptions
|
||||
var Client = mongodb.MongoClient;
|
||||
var mongoDbPromise = Client.connect('mongodb://localhost/test').then(client => client.db())
|
||||
var clientPromise = Client.connect(url);
|
||||
app.use(session({
|
||||
secret: 'secret',
|
||||
store: new MongoStore({ dbPromise: mongoDbPromise })
|
||||
store: new MongoStore({ clientPromise })
|
||||
}));
|
||||
|
||||
7
types/connect-mongo/index.d.ts
vendored
7
types/connect-mongo/index.d.ts
vendored
@ -1,6 +1,7 @@
|
||||
// Type definitions for connect-mongo
|
||||
// Type definitions for connect-mongo 3.0
|
||||
// Project: https://github.com/kcbanner/connect-mongo
|
||||
// Definitions by: Mizuki Yamamoto <https://github.com/Syati>
|
||||
// Guy Ellis <https://github.com/guyellis>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
@ -92,11 +93,11 @@ declare namespace connectMongo {
|
||||
}
|
||||
|
||||
export interface NativeMongoOptions extends DefaultOptions {
|
||||
db: mongodb.Db;
|
||||
client: mongodb.MongoClient;
|
||||
}
|
||||
|
||||
export interface NativeMongoPromiseOptions extends DefaultOptions {
|
||||
dbPromise: Promise<mongodb.Db>;
|
||||
clientPromise: Promise<mongodb.MongoClient>;
|
||||
}
|
||||
|
||||
export interface MongoStoreFactory {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user