Whenever I want to insert a new document, I receive the following error: MongoError: cannot index parallel arrays [english] [german]
What's the proper way to work with two unique arrays in MongoDB? What are alternatives to my approach?
My scheme:
const generalWordENSchema = new mongoose.Schema({
german: {
type: Array,
required: true
},
english: {
type: Array,
required: true
},
partOfSpeech: {
default: null,
type: String
},
example: {
default: null,
type: String,
},
defintion: {
default: null,
type: String,
},
image: {
default: null,
type: String,
},
audio: {
default: null,
type: String,
},
level: {
default: null,
type: Number,
},
});
generalWordENSchema.index({ german: 1, english: 1, partOfSpeech: 1}, { unique: true })
Example data:
{
"english": ["jacket"],
"german": ["Jacke", "Jackett", "Sakko"],
"partOfSpeech": "noun",
"example": "My jacket is brown and has two pockets.",
"definition": "",
"image": "",
"audio": "",
"level": ""
},