I need to create schema for following data structure:
{
...
matrix: [
[{type: "A", count: 6}, {type: "B", count: 4}],
[{type: "B", count: 1}, {type: "A", count: 2}, {type: "A", count: 1}],
[{type: "C", count: 7}, {type: "A", count: 1}],
]
}
I tried to do so like this while defining my schema, but it caused validation errors:
const cellSchema = new mongoose.Schema({
type: String,
count: Number
});
const matrixSchema = new mongoose.Schema({
...
matrix: [[cellSchema]]
});
it seems that such a schema syntax is supported now in Mongoose (https://github.com/Automattic/mongoose/issues/1361).

matrix: [[]]solves the problem. But what about defining schema forcellSchema?