1

I'm trying to get my fullcalendar working with mongodb, but I'm stuck while trying to fetch events from database and unfortunately when it comes to pulling from mongodb, it doesn't seem to have many resources out there.

In mongodb I have events stored as:

"availability" : `[ { "start" : "09.28.2018 11:00", "end" : "09.28.2018 16:00" }, { "start" : "09.28.2018 16:00", "end" : "09.28.2018 17:00" }, { "start" : "09.30.2018 16:00", "end" : "09.30.2018 23:00" }, { "start" : "10.25.2018 10:00:00", "end" : "10.25.2018 15:00:00" } ]`

NodeJS part of the code that opens the calendar:

router.get("/calendar", function(req, res){
... })

And I have tried to make ajax call(unsuccessfully):

$.ajax({
        url : '/calendar',
        type : 'post',
        dataType: 'json',
        success: function(e){
            if(e.success){
                var availability = [];
                $.each(e.availability,function(index,value){
                    availability.push({
                        title : value.title,
                        start : moment(value.start).format('YYYY-MM-DD'),
                        end : moment(value.end).format('YYYY-MM-DD'),
                    });
                });
                calendar.fullCalendar( 'addEventSource', availability);
            }
        }
    });

What do I need to fix to get calendar to fetch events from database stored as is?

  • You need to fix your dates as a first priority. `"09.28.2018 11:00"` is not a lexical format or a correct BSON Date as explained in the linked answers, and therefore does not work with the range search which is required. Fix the dates and then the demonstrated range query examples are what you want. – Neil Lunn Nov 24 '18 at 22:04
  • @NeilLunn I have fixed it now( I guess?) **"2018.11.15 11:00"**, but still confused how to get fullcalendar to fetch the events, Any tips on that? – niko nikić Nov 25 '18 at 20:08
  • Read the linked answers in the very large box above your question. – Neil Lunn Nov 25 '18 at 20:09

0 Answers0