db.event.insert() not working Node JS and MongoSkin

I had recently posted dhtmlx.com/blog/using-dhtmlxsch … h-node-js/

[code]
<!doctype html>

Basic initialization html, body{ margin:0px; padding:0px; height:100%; overflow:hidden; }
 
 
[/code]
//server.js
var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');

var db = require('mongoskin').db("mongodb://localhost:27017/testdb", { w: 0});
    db.bind('event');


var app = express();
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.bodyParser());


app.get('/init', function(req, res){
    if (err) throw err;
    console.log('before object');
    db.event.insert({ 
        text:"My test event A", 
        start_date: new Date(2017,5,1),
        end_date:   new Date(2017,5,5)
    }, console.log('first object run'));
    db.event.insert({ 
        text:"My test event B", 
        start_date: new Date(2017,5,19),
        end_date:   new Date(2017,5,24)
    });
    db.event.insert({ 
        text:"Morning event", 
        start_date: new Date(2017,5,4),
        end_date:   new Date(2017,5,4)
    });
    db.event.insert({ 
        text:"One more test event", 
        start_date: new Date(2017,5,3),
        end_date:   new Date(2017,5,8),
        color: "#DD8616"
    });
    res.send("Test events were added to the database");
    console.log('events inserted?')
});

app.get('/data', function(req, res){
    db.event.find().toArray(function(err, data){
        //set id property for all records
        for (var i = 0; i < data.length; i++)
            // console.log('in for loop');
            data[i].id = data[i]._id;

        //output response
        res.send(data);
        console.log('data sent');
    });
});

app.listen(3000);
console.log('listening on port 3000');

At the start I am running the Mongo Server, with the app’s own server. And I checked the mongo shell and found that the database exists. So the main issue is I can display data in my calendar only if I create it in the Mongo Shell, but I can’t insert the data through my server file.

I found that out from viewing the data from the shell on the calendar and from testing with console.log. It looks like my server isn’t even entering the “app.get(’/init’)” route and of course isn’t hitting the callback after. However, it is hitting my app.get(’/data’) route and displaying that data on the calendar.

I’m not sure where I’m getting it wrong, I checked the tutorial and I checked the MongoDB docs, and I haven’t found what what I’m missing. Any help would be appreciated.