title: Condition to check if python variable is present in Mongo DB field. If already exsists ignore oherwise push to DB
body: <pre><code>for file in files:
          if file and allowed_file(file.filename):
              templist = []
              ...
              string = ''.join([e[1] for e in sorted(license_info, key=lambda x:x[0])]) ## This is pushed to MongoDB in a field name ID.
              templist.append(string)
              currentdate = datetime.datetime.now().date()
              date = currentdate + relativedelta(years=1) ## This is pushed to MongoDB in a field name date.
              templist.append(str(date))
              df.loc[len(df)] = templist
  if collection.count_documents({}) == 0: ## If the table is empty I have pushed the dataframe directly in DB.
     collection.insert_many(df.to_dict('records'))
  else:
     ## Here is the help needed !!!
     If DB has some data I want to search the string value in the field &quot;ID&quot;, if it is present then corresponding &quot;Date&quot; value will be printed, else push the Field ID and date coming from above loop in the DB. This is to avoid duplicacy of data in field &quot;ID&quot;.
  </code></pre>
  <p>Example record format -</p>
  <pre><code>ObjectId('5f7ebd2e8827d15b764e9402'), 'ID': 'b0862b10-acd2-81e4-2991-086266236905', 'Date': '2021-10-08'}
  {'_id': ObjectId('5f7ebd2e8827d15b764e9403'), 'ID': 'b0862b10-acd2-81e4-2991-086266236905', 'Date': '2021-10-08'}
  </code></pre>
  <p>In the above example value of ID's in both the records are same, this I have to avoid and search in DB first in ID section from string coming from python loop. If exsist print the corresponding Date, otherwise do-not insert that string as Field value in ID as it is already there in DB.
  I am new to Mongo DB and wanted to do this in Python, suggest some thing...
  Thanks in advance!!</p>