Self referencing schema for versioning <p>I need to version documents in a collection, such that any changes to a document make a copy, and save the edited copy as 'current' and the previous version is preserved, along with time stamps, person editing, etc. I have designed a schema like:</p> <pre><code>var doc = new Schema; doc.Add({ created: Date, created_by:{type: ObjectId, ref: 'User'}, doc_id: String, doc_data: String, prev_docs:[doc] }); </code></pre> <p>So editing a doc would take the current doc, make a copy, and update the document, sticking current_doc into prev_docs, etc.</p> <ol> <li>Can a schema reference itself, like <code>prev_docs</code> does?</li> <li>Is this design pattern scalable in MongoDB? <code>prev_docs</code> would only ever be used as an audit trail, users would not generally see previous versions, and the would be excluded completely from most queries.</li> </ol>