title: How to save one document into two different collections of same database in mongodb
body: <p>I am working on nestjs and I want to fetch one document from collection_1 and save that same document into collection_2. I used $out aggregation but I only able to save one document in collection 2 at the same time but when I trying to save the second document then the first document has vanished. I want to save every document in collection 2 which is retrieved from the collection 1</p>
  
  <p>Service code:</p>
  
  <pre><code>async order(name){
      const list=await this.usersmodel.find({name:name}).exec()
      //return list
      try{
          if(list){
              const x=await this.usersmodel.aggregate([
                  { $match: { name: name } },
                  {$out:"payment"}
              ])
              return "data saved in payment collection"
          }
      }
      catch(error){
          return(error.message)
      }
  }
  </code></pre>
  
  <p>Controller code:</p>
  
  <pre><code>@Post('orderdata')
  async orderdata(@Body('name')name){
      return this.usersService.order(name)
  }
  </code></pre>