title: Insert many documents into empty collection, update if document with same key already exist for mongodb
body: <p>I have this list of dictionaries <code>json_data</code></p>
  
  <pre><code>json_data = [
    {
      "CODE": "018906",
      "X": "29813.66349",
      "Y": "28697.520760000003"
    },
    {
      "CODE": "018907",
      "X": "30041.8389",
      "Y": "28602.98724"
    },
    {
      "CODE": "018910",
      "X": "31966.120789999997",
      "Y": "29115.75337"
    },
  ]
  </code></pre>
  
  <p>I have this mongodb collection <code>code_col</code>.
  I want to insert <code>json_data</code> into collection <code>code_col</code> when the collecion is empty. There may be a new <code>json_data</code> next time and if the key <code>CODE</code> is the same, the document should be updated instead of inserted.</p>
  
  <p>I am using python 3.7, pymongo, mongodb 4.2.7.</p>