We have a list of products with blocks by date range:
[
{
id:1
blocks: [{
startAt: 160000000000, //timestamp
endAt: 16000000010, //timestamp
},{
startAt: 1600000020, //timestamp
endAt: 16000000030, //timestamp
},{
startAt: 1600000040, //timestamp
endAt: 16000000050, //timestamp
}]
},
{
id:2
blocks: [{
startAt: 160000000000010, //timestamp
endAt: 16000000010, //timestamp
}]
}, {
id:3
blocks: []
}, {
id:4
blocks: [{
startAt: 160000080, //timestamp
endAt: 16000000090, //timestamp
}]
}
]
We need to exclude the records in the index that have locks in the date range defined by the customer
{
customerAvailability: {
start: 1600000020,
end: 1600000030
}
}
Example:
if the customer uses this availability range
{
customerAvailability: {
start: 1600000019,
end: 1600000029
}
}
The result should be
[
{
id:2
blocks: [{
startAt: 160000000000010, //timestamp
endAt: 16000000010, //timestamp
}]
}, {
id:3
blocks: []
}, {
id:4
blocks: [{
startAt: 160000080, //timestamp
endAt: 16000000090, //timestamp
}]
}
]
This would be easy if ORs worked like in other languages. We also tried to solve it with TO but we didn’t get the result.
Interestingly, we tried a simple OR example and didn’t get a logical result:
blocked_dates.endAt = 16000000050 OR blocked_dates.endAt = 16000000090
.
Some of this we are not understanding well ? we searched the documentation and it does not explain the case.