I'm building a Calendar based application where there are events in a calendar. Events can be recurring (daily, weekly, monthly, quarterly, bi-annually and annually).
Each event document has a default name
, defaultDate
and description
but also contains an array (userData
) of objects that are associated with each user (userDate
, userDescription
). Although the events are centralised, some users have their own userDate
which isn't the default and each user is able to set their own userDescription
for the event. That's why the userData
object exists.
To clarify, the event document looks something like this:
{
_id: '1234567',
name: 'Event One',
description: 'This is the default description',
defaultDate: '2017-02-15T12:00:00.000Z',
userData: [
{
userId: '8765432',
userDate: '2017-06-10T12:00:00.000Z',
userDescription: 'My personalised description',
},
{
userId: '461938',
userDate: '2017-03-21T12:00:00.000Z',
userDescription: 'I have a description too!',
},
]
}
I'm trying to work out the best way to handle storing recurrences of these events when they are created. When the event is edited it needs to edit all other copies of the event too. There will never be a scenario where a single event needs to be edited but the recurrances are left untouched.
When the events are created, I have a HTML select which asks if the event is recurring and has the following options: none, daily, weekly, monthly, quarterly, bi-annually, annually
If anyone can advise the best way to create recurring copies of these events I would appreciate it!