I have a Database in Mongo. I need to find all the samples within a particular time.
[
{
deviceid: 1,
bucketSize: 4,
first: 1573833152,
last: 1573833155,
samples: [
{
val: 10,
time: 1573833152
},
{
val: 15,
time: 1573833153
},
{
val: 14,
time: 1573833154
},
{
val: 20,
time: 1573833155
}
]
},
{
deviceid: 1,
bucketSize: 4,
first: 1573833156,
last: 1573833160,
samples: [
{
val: 10,
time: 1573833156
},
{
val: 15,
time: 1573833157
},
{
val: 14,
time: 1573833158
},
{
val: 20,
time: 1573833159
},
{
val: 20,
time: 1573833160
}
]
},
{
deviceid: 1,
bucketSize: 4,
first: 1573833161,
last: 1573833165,
samples: [
{
val: 10,
time: 1573833161
},
{
val: 15,
time: 1573833162
},
{
val: 14,
time: 1573833163
},
{
val: 20,
time: 1573833164
}
]
}
]
Eg: samples between 1573833152 and 1573833156
should yield
samples: [
{
val: 10,
time: 1573833152
},
{
val: 15,
time: 1573833153
},
{
val: 14,
time: 1573833154
},
{
val: 20,
time: 1573833155
}, {
val: 10,
time: 1573833156
}
I tried all methods but failed to extract the required results. Thank You So much in advance.I tried using $or, $elemMatch. But as I am new to Mongo I failed. If someone can please help