Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

292
Vistas
Mongoose and connect-mongo

I am using mongoose for managing relationships between data and I am trying to use connect-mongo to store specific sessions in the database.

It looks like that we need to connect twice to the db, one with mongoose and another one with connect-mongo.

I am using the following code to initialise a connection for mongoose

await mongoose.connect(this._connectionUrl, this._connectionOptions);

Initialising a new store every time (not sure if I am correct regarding code initialisation).

app.use(session({
            // secret: config.sessionSecretKey,
            secret: "secretkey",
            resave: true,
            saveUninitialized: true,
            cookie: { maxAge: 19 * 60000 }, // store for 19 minutes
            store: MongoStore.create({
                mongoUrl: this._connectionUrl,
                mongoOptions: this._connectionOptions // See below for details
            })
        }))

Is there any way that I can pass the connection from mongoose to mongo-connect Store?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

i'm lookin for a solution too and just read this on the "migration guide" of connect-mongo

For the options, you should make the following changes:

Change url to mongoUrl Change collection to collectionName if you are using it Keep clientPromise if you are using it mongooseConnection has been removed. Please update your application code to use either mongoUrl, client or clientPromise To reuse an existing mongoose connection retreive the mongoDb driver from you mongoose connection using Connection.prototype.getClient() and pass it to the store in the client-option. Remove fallbackMemory option and if you are using it,

and there's this example https://github.com/jdesboeufs/connect-mongo/blob/master/example/mongoose.js

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda