Bucket Pattern - Chat example discussion

When we bucket data by channel_id and date it seems easy to implement day-by-day loading of messages in client application, starting from most recent dates to older dates. However in reality, clients are operating in different timezones, and they want to see messages grouped according to their local timezone, not the server one. I don’t see how solution in example can solve that problem. Any ideas how can we improve it or how can we organize data loading on client side?

Schema from example :

“channel_id”: “<string>”,
“name”: “<string>”,
“date”: “<date>”,
“messages”: [ “<string>” ]

I should first of all point out that any schema mentioned in the lectures is not a solution. And I think that the tutor mentioned this in the beginning of the course.

Timezones is a pretty big topic and one that can’t be explained in a one-liner. This timezone problem/conundrum is not specific to MongoDB, it’s a generic problem! Suggest you read up on Timezone integration that’s specific to your driver and incorporate it into your schema design. The easiest solution is to store the timestamps as UTC and save the name of the timezone so that you can use your driver to convert to the appropriate tmz timestamp for display purposes.


I understand that example != solution; but example can be basis for something useful, right? I liked the idea of bucketing messages by day (I work with chats / chatbots by the way, and it make sense to me), now I’m trying to think can the example led to real solution or it’s an dead end.

I’m sure that they’re more well behaved than us humans :slight_smile:

Indeed! I think this pattern is best suited for use-cases that have very high volume + high frequency of data. I’m guessing your application is a two-way system, i.e. your chatbot colleagues are chatting away with one human and not a group of humans in single channel? I could be wrong so perhaps you can enlighten me?