Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialali mur
UX Design Techdegree Student 23,377 Pointsmongoose remove duplicates
I want to repeat the below mysql query with mongoose query
"DELETE n1 FROM names n1, names n2 WHERE n1.id > n2.id AND n1.kod = n2.kod AND n1.shop = n2.shop"
This query basically removes duplicate entries from my table .
1 Answer
Ken Alger
Treehouse TeacherAli;
It looks like you want to be using the $lookup aggregation operator to be able to perform that left outer join for comparison purposes. You might need a few other steps as well in the aggregation pipeline depending on your database schema design. One such example would be if your values are an array you will need to use $unwind.
Keep in mind that $lookup
is only available in MongoDB versions 3.2 and higher.
Post back with further questions or information about your schema.
Happy coding,
Ken