I have so complicated schema which had an inner array each array element contains one more level array. But how to update data inside arrays of the second level.
I need to update services array but how to get access? I have _id of Item, thread number, shift number (Can be only 3 and this not array due to three level arrays it's so hard), and service name.
I need something like (pseudocode)
getByItemId(id)
.getByThreadNumber(tNumber)
.getByShift(numberShift)
.getByServiceName(name)
.updateLogInCounter(newValCounter)
const itemSchema = new Schema({
threads: [
{
number: {
type: Number,
requred: true
},
{
firstShift: {
"someData": ... ,
"services": [
"name": {type: String}
"lastUpdate": {type: Date},
"logInCounter": {type: Number}
]
},
secondShift: {
"someData": ... ,
"services": [
"name": {type: String},
"lastUpdate": {type: Date},
"logInCounter": {type: Number}
]
},
thirdShift: {
"someData": ... ,
"services": [
"name": {type: String},
"lastUpdate": {type: Date},
"logInCounter": {type: Number}
]
}
}
}
]
})
Maybe this data structure incorrect and this impossible? Maybe I need to create many collections? Maybe some plugin helps me. Or it's normal, if yes how to get my target data?