How can we ensure a unique property is generated for a mongodb/mongoose model upon creation? What would be the most effective method to verify if the created value is not already in use and generate an alternative value before saving?
let schema = new Schema({
name: {type: String},
uniqueProperty: {type: String, unique:true, default:generateUniqueProp} // The current approach only works if the generated Value isn't already taken
})