If I have a collection that is filled with:
db.Dater.insert({"Name" : "Ann", "Gender" : "F", "GenderSearch" : "M" })
db.Dater.insert({"Name" : "Bob", "Gender" : "M", "GenderSearch" : "F"})
db.Dater.insert({"Name" : "Cat", "Gender" : "F", "GenderSearch" : "F"})
How can I write a query to get all the pairs of names where the key is the Name, the value is a list of Names where value.Gender = key.GenderSearch?
In SQL the desired results would be (although this is not a key to list value)
SELECT d1.Name, d2,Name
FROM Dater d1
JOIN Dater d2 ON d1.GenderSearch = d2.Gender