title: How to transfer data of one collection into another of mongodb
body: <p>Am working on nestjs.I have two collections one in orders and second is payment and i want to retrieve one single entry from orders collections and save that same entry into payment collection.</p>
  
  <p>Here is the code of services:</p>
  
  <pre><code>async order(name){
      const list=this.usersmodel.find({name:name}).exec()
      //return list
      try{
          if(list){
              const x=this.usersmodel.aggregate([
                  {$out:"payment"}
              ])
              return "data saved in payment collection"
          }
      }
      catch(error){
          return(error.message)
      }
  }
  </code></pre>
  
  <p>Here is the code of controller:</p>
  
  <pre><code>@Get('orderdata')
  async orderdata(@Body('name')name){
      return this.usersService.order(name)
  }
  </code></pre>
  
  <p>By using these code lines neither i got desired output nor i got any error. I got "data saved in payment collection" when am hitting API in postman but i didn't get the entries in my payment collection.</p>