Modeling availability and time slots in MongoDB for auto-assigning tradesmen #170287
-
|
How do you model availability and time slots in MongoDB to efficiently support auto-assignment of tradesmen? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Hi, I’d usually keep it simple with three collections:
When auto-assigning, you:
If you need speed, you can pre-generate discrete time slots (e.g. 15-min blocks) and just Everything stored in UTC, and convert back on display. |
Beta Was this translation helpful? Give feedback.
-
|
Two main ways to model availability in MongoDB: Slot-based model (pre-generated time slots like 09:00–10:00)
Efficiency Use indexes on trade, availability.start, availability.end (and location if needed). For large scale, shard by location or trade type. Auto-assignment flow Filter by trade + location Check availability (slot or range) Exclude overlapping bookings Apply tie-breakers (nearest, least busy, earliest slot) |
Beta Was this translation helpful? Give feedback.
Hi,
I’d usually keep it simple with three collections:
When auto-assigning, you:
bookedCount < capacity.If you need speed, you can pre-generate discrete time slots (e.g. 15-min blocks) and just
findOneAndUpdatewith a condition on bookedCount, which makes the assignment atomic.Everything stored in UTC, and convert back on display.