Answer the question
In order to leave comments, you need to log in
How to make Mongoose ignore empty values in an array, with a unique parameter?
I have a schema
const schema = new mongoose.Schema({
...account,
characters : [
{ ...character },
],
stats,
});
const character = {
name: { type: String, required: true, unique: true },
}
admin.players index: characters.name_1 dup key: { : null }
Answer the question
In order to leave comments, you need to log in
setting sparse: true solves the problem, but values can be repeated in this array, except for arrays of other documents...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question