Generating globally unique ids inside of an event function

is there a way to create a uuid in an event function something like:

function OnUpdate(doc, meta) {
if (doc.type === ‘car’) {
dest[uuid()] = {
type: ‘car’,
externalId: meta.id
}l
}

Hi bfwarner,

As you may be aware, to generate a proper UUID, you’d need some source of uniqueness such as a network card’s mac address. Unfortunately, it’s not possible to access this from eventing javascript handlers today.

So you can get a fairly unique ID by using random numbers, and/or timestamps and formatting it into UUID. There is an example of this here: https://www.w3resource.com/javascript-exercises/javascript-math-exercise-23.php

If you have a use case for proper UUID that are guaranteed to be unique, please email us (I’ll PM the email id) and we can add it to the feature requests we’re considering, it’ll be fairly easy to implement.

Best Regards,
Siri