In Javascript for Automation, one can create an element object and then add it to a container. For instance:
var cal = Application('Calendar')
var newEvent = cal.Event(
{
summary: todoSummary,
startDate: new Date(),
endDate: endDate
}
);
cal.calendars[0].events.push(newEvent);
}
This method of working is nicely described and documented in many places, such that Calendar (iCal) does not need to have its own methods for doing this.
How though does one remove an object (Event, etc.) from the container (events), or at least delete the relationship between this event and its calendar? In AppleScript one would write:
delete (every event whose uid is eventID)
So it would seem that the JXA version would be something like:
cal.calendars.events.delete.whose({uid: event.uid()})
But various attempts just give me invalid key forms
or Can't convert types
errors. Thanks!