Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!