I have a mongoose schema,
const loggerSchema = mongoose.Schema(
{
// Other ...
cluster: {
type: String,
required: true,
},
// ...
}
)
It currently filled with lots of data. I want to modify the cluster
property to be as follows
const loggerSchema = mongoose.Schema(
{
// Other ...
cluster: {
type: String,
required: true,
unique:true
},
// ...
}
)
How do I achieve this without losing any of my data (in DB)? Provided that all existing data contain unique values on cluster
attribute.