title: MongoDB - move documents to archive and delete them from original collection
body: <p>I have two collections:</p>
  
  <ul>
  <li>A (original) </li>
  <li>B (archive)</li>
  </ul>
  
  <p>I want to move all documents, which match some condition, to collection B (archive) and original documents from collection A remove. I use Python and so far I have this:</p>
  
  <pre><code>db.A.aggregate([{"$match": {"$and": [{"attribute1": False}, {"attribute2": False}]} }, {"$out": "B"} ])
  
  db.A.deleteMany({"$and": [{"attribute1": False}, {"attribute2": False}]})
  </code></pre>
  
  <p>Both commands work, but when I call <em>deleteMany</em> on collection A it also deletes new documents in archive B. I guess Mongo keeps it like one object and share some kind of pointer and that's why it removes from both collections. Any idea how to solve it? </p>