Parse.com and parse-server different behaviour in storing date in a object field
Describe your issue in as much detail as possible:
If i have a Object field and i want to store a key containing the date object, then the parse.com used to store it as a date object whereas the parse-server stores it as a date string. The case and reproduction steps are listed below:
Say i have a date object:
var dateToSave = new Date();
var dateObject = {lastViewed: dateToSave}
var DummyDateCollection = new Parse.Object.extend('DummyDateCollection');
var dc = new DummyDateCollection({dateObjectField: dateObject});
return dc.save().then(function(dc){ console.warn(dc)});
Expected Result
The expected result for the field "dateObjectField" is: {"lastViewed":{"__type":"Date","iso":"2016-08-29T04:46:28.903Z"}}
Actual Outcome
{"lastViewed":"2016-08-29T04:46:28.903Z"}
Environment Setup
- Server
- parse-server version: 2.2.18
- Operating System: Linux
- Localhost or remote server? : AWS
- Database
- MongoDB version: 3.0.2
- Storage engine: RocksDB
- Localhost or remote server? : AWS
I have also added a pull request for this: https://github.com/ParsePlatform/parse-server/pull/2607
Please review it.
@shivangagarwal we'll have a look shortly
I've had a chance to check against parse.com and the current state is misleading.
var dateToSave = new Date();
var dateObject = {lastViewed: dateToSave}
var DummyDateCollection = new Parse.Object.extend('DummyDateCollection');
var dc = new DummyDateCollection({dateObjectField: dateObject});
dc.save().then(function(dc){
// the date is in object format
console.warn(dc)
dc.fetch().then(function(dc) {
// date will be in string format.
console.warn(dc);
});
});
The current state of parse-server is compliant with parse.com, without the fetch it's in date format, and after fetch it's a string.