I am trying to create a network card based on the mentions of Twitter users. I store data in MongoDB and cannot figure out how to remove unwanted users.
Examples of db docs:
{
'user': 'user1'
'mentioned_users: ['user2', 'user3']
}
{
'user': 'user2'
'mentioned_users: ['user1', 'user3']
}
An example of the desired result:
{
'user': 'user1'
'mentioned_users': ['user2']
}
{
'user': 'user2'
'mentioned_users': ['user1']
}
user3 exists both in user1 and in user2 list of mentioned users, however user3 is extraneous because user3 does not have his own document in the collection.
I need either a filter using db.collection.find () or another method so that I can get rid of all unauthorized users.
Is there an easy way to do this with pymongo, or should I create a python solution?
source
share