Skip to content

Commit d1ee901

Browse files
Merge pull request #208 from CloudBoost/staging
Staging
2 parents 5e2f5a7 + 5b399d5 commit d1ee901

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

services/cloudObjects.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,9 @@ function _save(appId, collectionName, document, accessList, isMasterKey, reqType
286286
_validateSchema(appId, listOfDocs, accessList, isMasterKey).then(function(listOfDocs) {
287287
console.log("Schema checked");
288288

289-
var mongoDocs = JSON.parse(JSON.stringify(listOfDocs)); //making copies of an array to avoid modification by "call by reference"
289+
var mongoDocs = listOfDocs.map(function(doc){
290+
return Object.assign({},doc)
291+
})
290292

291293
promises.push(databaseDriver.save(appId, mongoDocs));
292294
global.q.allSettled(promises).then(function(array) {
@@ -438,6 +440,14 @@ var _isSchemaValid = function(appId, collectionName, document, accessList, isMas
438440
continue; //ignore.
439441

440442
if (document[columns[i].name] === undefined) {
443+
//TODO : check type for defaultValue , convert to date of type is DateTime , quick patch , fix properly later
444+
if(columns[i].dataType === 'DateTime'){
445+
try{
446+
columns[i].defaultValue = new Date(columns[i].defaultValue)
447+
} catch(e){
448+
columns[i].defaultValue = null
449+
}
450+
}
441451
document[columns[i].name] = columns[i].defaultValue;
442452
}
443453

@@ -517,7 +527,7 @@ var _isSchemaValid = function(appId, collectionName, document, accessList, isMas
517527
if (key === '_tableName' || key === '_type' || key === '_version')
518528
continue; //check id; //ignore.
519529
else if (key === '_id') {
520-
//check if this is a string.
530+
//check if this is a string..
521531
if (typeof document[key] !== 'string') {
522532
mainPromise.reject('Invalid data in ID of type ' + collectionName + '. It should be of type string');
523533
return mainPromise.promise;

0 commit comments

Comments
 (0)