title: Mongoose set "id" property of document to be equal to "_id" of the document by default
body: <p>I have a Model that needs to have &quot;id&quot; property. Since it needs to be unique, I want set its value to be the same as &quot;_id&quot; property of the document after creation. So, my Model looks something like this:</p>
  <pre><code>const modelSchema = new Schema(
    {
      id: { type: String, unique: true },
      property_1: { type: String, unique: false }
      property_2: { type: String, unique: false }
      ...
    }
  );
  </code></pre>
  <p>For now, I do this with 2 different queries, one for creation of document, and one for updating the &quot;id&quot; property with the value of &quot;_id&quot;, after document is created.</p>
  <pre><code>Model.create({
      propery_1: value_1,
      propery_2: value_2,
      ...
  }).then((document) =&gt; {
      document.id = document._id;
      document.save();
  })
  </code></pre>
  <p>Is there a way to define my Schema to support this by default (&quot;id&quot; property will be automatically set to value of &quot;_id&quot;). Or can I replace this two queries with one that will have the same functionality.</p>