function(doc, req) {
    if (!doc) doc = {};
    if (!req.body) return [null, "No document to insert"];
    var _ref = JSON.parse(req.body);
    for (k in _ref) {
        doc[k] = _ref[k];
    }
    if(_ref['timestamp'] == undefined){
       var dt = new Date();

        var year = dt.getFullYear();
        var month = dt.getMonth()+1;
        var day = dt.getDate();

        var hours = dt.getHours();
        var minutes = dt.getMinutes();
        var seconds = dt.getSeconds();

        if (month < 10)month = '0' + month;
        if (day < 10)  day = '0' + day;

        if (hours < 10)hours = '0' + hours;
        if (minutes < 10) minutes = '0' + minutes;
        if (seconds < 10) seconds = '0' + seconds;

        doc.timestamp = year + "/" + month + "/" + day + " " + hours + ":" + minutes + ":" + seconds;
    }
    if(_ref['time'] == undefined){
        var milliseconds = (new Date).getTime();
        doc.time = (milliseconds/1000).toFixed(0);;
    }
    return [doc, JSON.stringify({msg : 'Success'})];
}
