Alright I was able to solve it with the following code. The a
and b
were pymongo cursors which for some reason (I would be glad to hear if somebody knows) didn't behave as dictionaries.
a = db.col.find()
bjects = []
for object in a:
objects.append(object)
for i in objects:
for q in objects:
if i['_id'] <> q['_id'] and i['user_id'] == q['user_id']:
edges.insert({'source':i['id'],'target': q['id']})