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

444
Vistas
'MongooseError: Callback must be a function, got [object Object]' When using "updateMany" function

Ignore the messy code. I've been working for hours on end and haven't had time to organize it.

I keep getting this error everytime the messageCount is 100 or more.

const profileData = await Profiles.findOne({
    userID: message.author.id
});
if (!profileData) return console.log('re')
try {
    if (profileData.messageCount >= 100) {
        console.log('yeet')
        await Profiles.updateMany({
            userID: message.author.id
        }, {
            messageCount: 0,
        }, {
            $inc: {
                caseCount: +1
            }
        }, {
            upsert: true
        });
    } else {
        console.log('na')
    }
} catch (error) {
    console.log(error);
}
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The updateMany() method needs only 3 parameters, it expects the fourth parameter to be an optional callback function, but you used an object, which explains the error message.

Combine your set and inc parameters like this:

await Profiles.updateMany(
  {
    userID: message.author.id
  },
  {
    $set: { messageCount: 0 },
    $inc: { caseCount: 1 },
  },
  {
    upsert: true
  }
);

Check the docs for more information.

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