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

102
Vistas
How do I search the mongoose data with with multiple properties?

I made a team by users(userID), now i want to search if that user is present in the team or not.

exports.start = async (message) => {

const check = await group.find({userID1:message.author.id} ||{userID2:message.author.id} || {userID3:message.author.id})
console.log(check);
}

My database looks like this

{
    "_id" : ObjectId("6173107fcf643f15e1fced83"),
    "userID1" : "769819933390667796",
    "userName1" : "Davion",
    "userID2" : "247276609894219777",
    "userName2" : "Davion",
    "userID3" : "898413310872006716",
    "userName3" : "Davion",
    "team" : "3",
    "__v" : 0
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

$or like logical or operator

exports.start = async (message) => {
  const check = await group.find({
    $and: [
      {
        $or: [
          { userID1: message.author.id },
          { userID2: message.author.id },
          { userID3: message.author.id }
        ]
      }
    ]
  })
  console.log(check);
}

$and performs a logical AND operation on an array of one or more expressions (expression1, expression2, and so on) and selects the documents that satisfy all the expressions.

exports.start = async (message) => {
  const check = await group.find({
    $and: [
      { userID1: message.author.id },
      { userID2: message.author.id },
      { userID3: message.author.id }
    ]
  })
  console.log(check);
}
about 4 years ago · Juan Pablo Isaza 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