Saving to MongodB with Schema as string even though Date type defined


#1

I have a collections with aldeed:schema for validation:

FutureTasks = new Meteor.Collection('future_tasks');

var Schemas = {};

Schemas.FutureTask = new SimpleSchema({
    start_date: {
        type: Date, //String -> Date
        label: "START_DATE",
        max: 20  
  },

FutureTasks.attachSchema(Schemas.FutureTask);

But I was able to insert myModifiedStartTime, which is of type string, in with no warnings in server.js as?:

            var rawStartTime = contentObj.records[i].start_date;  
            var myModifiedStartTime = moment(rawStartTime, "YYYY-MM-DD HH:mm:ss").subtract(1, 'hours').format("YYYY-MM-DD HH:mm:ss");

            FutureTasks.upsert({
                    number: contentObj.records[i].number,
                }, {
                    // Modifier
                    $set: {
                        start_date: myModifiedStartTime,
                        end_date: myModifiedEndTime
                    }
                }

When working with MongodB and Date objects, is it better to save into MongodB as string or Date is preferred?

Use case is : reading in original start_date from one RESTful service in string, and modifying time information as well as saving into MongodB, before sending out again to another RESTful call using modified time information in a typical cron job scenario…