Invalid data in mongoDB after insert of an ISO data

廉价感情. 提交于 2019-12-12 06:07:13

问题


I try to store a record based on a dayClick event out of the jquery fullcalendar. According to the consol log the date is provided as: locale: Object, _d: Date 2015-03-19T00:00:00.000Z, then I pass it to ce.start and ce.end, when I check the database I have 'Invalid date' as value in calevnt.start and calevent.end --- What's wrong here?

On the client:

Template.calendar.helpers({
options: function() {
    return {
        lang: 'de',
        dayClick:function(date,allDay,jsEvent,view){
            var ce = {};
            ce.start = date;
            ce.end = date;
            ce.color = 'red';
            ce.className = 'todo';
            ce.project = Session.get('active_project');
            ce.title = ' Jour Fixe2';
            ce.owner = Meteor.userId;
            console.log(date,allDay,jsEvent,view);
            Meteor.call('addCalEvent',ce);
        }
    }
}
});

On the server:

'addCalEvent': function (calevent) {
 if (!calevent.type) {
    calevent.type = 'milestone';
  }
  return Calevents.insert(calevent);
},

回答1:


try

Template.calendar.helpers({
    options: function() {
        return {
            selectable: true,
            selectHelper: true,
            lang: 'de',
            select: function(start, end, allDay) {
                var ce = {};
                ce.start = start.format(); // return moment date
                ce.end = end.format(); // return moment date 
                ce.color = 'red';
                ce.className = 'todo';
                ce.project = Session.get('active_project');
                ce.title = ' Jour Fixe2';
                ce.owner = Meteor.userId;
                console.log(start, end);
                Meteor.call('addCalEvent',ce);
            }
        }
    }
});


来源:https://stackoverflow.com/questions/29117863/invalid-data-in-mongodb-after-insert-of-an-iso-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!