I have to build an app that manages orders between customers who submit the orders and riders who deliver them. Riders work in shifts, so when a customer submits an order, only the riders that are active in that particular shift should recieve a notification.
I chose Firebase as backend for my app, so I’d use cloud firestore, cloud functions, auth and FCM.
My question is: how should I organize my data to achieve what I’ve mentioned before?
I’ve already made some options:
- I have a collections for shifts, where all riders active in that shift are recorded. When an order is submitted, then i query all the riders active in that shift (queried by time) and then send a notification to each one.
- I have a message topic where active riders are subscribed, and then i post the notification there.
Option #1 seems too cumbersome for me. There are a lot of queries to do. Option #2 doesn’t need a query at all, but how should i handle riders subscriptions to it (to be more precise, how can active riders in that shift subscribe to the topic) ?