Recurring Events Schema w/ MongoDB -
i've read of papers out there describing data storing methods recurring events, i'm still trying wrap head around best practice, concerning mongodb.
my main concern cheaply retrieve of events occur within given timeframe. secondary concern modify , alter single occurrences without taking entire event chain out of whack.
looking @ others have asked similar questions, have come possibility. i'm not sold on it, , love pointers in right direction.
my idea: within each event document, have...
- a recurring string field closely matches ical standard
- an "occurrences" embedded document or array field contains changes/edit on specific occurrences (such changing description or start time, or canceling single occurence).
- an occurrence start , end field define queried boundaries of recurrence rule
pros:
- able store changes , still maintain association other events
- easily queried, model on business side have construct each event though
cons/potential problems:
- if editing event, , user decides mark changes applying "all events" - how keep events have past being altered
this seems approach me. "keep events have past being altered" mark them boolean flag says so. should able use flag , start/end date while querying , updating.
alternatively, could: - set end date original event - clone event, , set new start , end date on new event. - empty out occurences field on cloned event
something doing this:
before:
{ 'title' : "gin o'clock", 'recurrance' : 'daily', 'start_date' : '2012-01-01 17:00', 'end_date' : false, 'occurences' : [ { 'date' : '2012-06-03 17:00', 'title' : "jubilee gin o'clock" } ] } after:
{ 'title' : "gin o'clock", 'recurrance' : 'daily', 'start_date' : '2012-01-01 17:00', 'end_date' : '2012-06-05 17:00, 'occurences' : [ { 'date' : '2012-06-03 17:00', 'title' : "jubilee gin o'clock" } ] }, { 'title' : "gin o'clock our earlier", 'recurrance' : 'daily', 'start_date' : '2012-06-06 16:00', 'end_date' : false, 'occurences' : [ ] } hope helps!
Comments
Post a Comment