title: Magento 2 - How to save data after the order was successfull in a custom table
body: <p><strong>First:</strong> I understand how to create a custom module within a customtable in the backend. I had already done this and it works fine and I can save some information with it in the backend.
  (Name: app/code/TestModule/Module)</p>
  <p>But now I try to customize the order process.
  I want to save some data, like the 'oder_id' and the 'order_date' in a custom table.</p>
  <p>This process should work automatically after the order was successful.</p>
  <p><strong>Problem:</strong>
  I don't understand how I can store this information in a custom table.</p>
  <p>I have this in my <strong>success.phtml</strong> for checking the data in the frontend:</p>
  <pre><code>&lt;?php 
  $block-&gt;getOrderId()
  $block-&gt;getShippingMethod() 
  ?&gt;
  </code></pre>
  <p>The data is called with a function, here in my <strong>Block/Onepage/Success.php</strong></p>
  <pre><code>...
  
  public function getShippingMethod()
  {
      return $this-&gt;_checkoutSession-&gt;getLastRealOrder()-&gt;getShippingMethod();
  }   
  
  ...
  </code></pre>
  <p>Well, and now I don't have any ideas for the next steps. For example, I saw this tut here <a href="https://stackoverflow.com/questions/31983546/in-magento-2-what-is-the-correct-way-for-getmodel/31984198">In magento 2 what is the correct way for getModel?</a> but it does not help me.</p>
  <p>Other questions on stackoverflow answer only how to build a module or how to show order information.</p>
  <p>I think i have to do something like this:</p>
  <pre><code>    $this-&gt;_Modulename-&gt;addData($data);
      $this-&gt;_transaction-&gt;save();
  </code></pre>
  <p>But after 3 days of reading, I try my luck here.
  I don't need a final solution and I don't want a copy and paste of the answer code, I just won't understand how this &quot;save data in the custom table after success&quot; works.</p>
  <p>I take everything from you guys because I am at the end of my knowledge.</p>
  <p>TYIA</p>