Create a DocumentDB post type trigger to store document edit history
<p>I want to create a post trigger to save the old content to another document when someone modifying a document. I really didn't find a lot of sample codes about DocumentDB triggers on Internet so I hope I can get some help here... <br/></p>

<p>If in SQL Server, I would create a After trigger on UPDATE and use Inserted and Deleted temp tables to track table modification history. </p>

<p>For example, in SQL it would be</p>

<pre><code>Insert Into TableToStoreHistory
Select {some columns} From inserted i JOIN deleted d
ON i.id = d.id
</code></pre>

<p>I know in DocumentDB, the java script code will be totally different. I wish I could come up with some code first by myself. However, I didn't find one closer example showing how to do this in DocumentDB post trigger.</p>

<p>Let's say my document is defined like below:<br/></p>

<p>Document A<br/></p>

<pre><code>{
    "id": "1",
    "content": "Hello World!"
}
</code></pre>

<p>And I want the post trigger write into another document when someone modify Document A. The old content will be written into Document B maybe like below<br/></p>

<pre><code>{
    "id": {assign some other id maybe "1_date&amp;time"},
    "oldContent": "HelloWorld"
}
</code></pre>

<p>Can anyone help, please?</p>

<p>Thank you very much!</p>