Recently I noticed that my UUIDv4 generator is having a high rate of collision. I use it to generate UUIDs for my mongodb objects like this:
const mongoose = req
The problem with your code is UUID will be generated one time, and it will use that same default value.
You need to use function form of default like this to generate a different uuid every time:
UUID: { type: String, required: true, default: () => uuid() }