How to generate UUID using mongodb scripting
<p>I plan to write a script to alter mongodb tables and fields based on this source: <a href="https://docs.mongodb.com/manual/tutorial/write-scripts-for-the-mongo-shell/" rel="noreferrer">https://docs.mongodb.com/manual/tutorial/write-scripts-for-the-mongo-shell/</a></p>

<p>I plan to generate a UUID and put in a new field to be added to the altered tables, I found this reference <a href="https://docs.mongodb.com/manual/reference/method/UUID/" rel="noreferrer">on how to generate a BSON UUID object</a>
but there's a need for me to specify <strong>a 32-byte hexadecimal string to convert to the UUID BSON subtype</strong>. Ideally I'm looking for a mongodb equivalent to <a href="https://www.npmjs.com/package/uuid" rel="noreferrer">this</a> which it auto generates UUID v1 by creating a random hash itself without the need of a 32-byte hexadecimal input. How is this done? I plan to create a script on this which mongodb will execute.</p>