I'm trying to set up a time series in mongodb (using this as a guide). Let's say that I have a collection where each document looks like this:
{
_id: '...',
timestamp_minute: '2018-01-01T12:30:00.000Z',
numbers: [[1, 2, ..., 10], ..., [1, 2, ..., 10]],
letters: [[a, b, ..., j], ..., [a, b, ..., j]]
}
How can I unwind it so it looks like this:
[
{_id: '...', timestamp_minute: '2018-01-01T12:30:00.000Z', values: 1, letters: a},
{_id: '...', timestamp_minute: '2018-01-01T12:30:00.000Z', values: 2, letters: b},
{_id: '...', timestamp_minute: '2018-01-01T12:30:00.000Z', values: 3, letters: c},
...
]
The data is stored on a document-per-minute basis with tenth-of-a-second precision. That means that the first level of values is usually length 60 (the seconds in a minute), and each nested one is length 10 (the tenth-of-a-second in a second).
I want to be able to unwind it in order to generate aggregated data.