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

208
Views
Pug iteration give me duplicate data

so i used pug loops to show 2 docs of my collection but when it's going to show them, it shows them twice. here is the code:

            each request in requests
              -if(request.course.master.id===user.id)
                each reqUser in request.course.users 
                  tr
                    td=request.course.name
                    td=reqUser.name
                    td=reqUser.email

this is a request doc of my requests collection ===>

_id:61c879ab1fd17239e85a8b7a
duration:Array
price:Array
createdAt:2021-12-26T14:16:55.302+00:00
expiresAt:
2022-01-25T14:16:55.302+00:00
accepted:true
course:ObjectId("61b60458acbb1fa4598eea36")
user:ObjectId("61c879941fd17239e85a8b68")
id:"63341"

i have access to the course of this request and i want the user of this course.

also this is the course doc of my courses collection ===>

_id:ObjectId("61b3708276844971620c98ea")
images:Array
users:Array
name:"assembly "
imageCover:"course-assembly"
duration:Array
master:ObjectId("61c2bfc0ac2f110af04903a2")

in the pug code up there , first i want to check if the current logged in user is the master of the given course or not; then if it's true i want to make a row for each user of the course but it gives 2 completely same rows for each user in this shape ===>

  1. courseName , user1Name , user1Email
  2. courseName , user2Name , user2Email
  3. courseName , user1Name , user1Email
  4. courseName , user2Name , user2Email
about 4 years ago · Santiago Trujillo
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!