Closed
Description
New Issue Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
- I can reproduce the issue with the latest version of Parse Server.
Issue Description
If we try to create an object with below code
const myObj = new Parse.Object('Company3');
await myObj.save({
prop1: 'test1',
prop2: {
test: {
date: new Date()
}
},
prop3: {
date: new Date()
}
}, {useMasterKey: true});
This is how the saved object in mongo DB looks like
{
"_id": "5DTIqZcZv9fhbHu0qTZq",
"prop2": {
"test": {
"date": {
"__type": "Date",
"iso": "2021-09-14T14:50:37.303Z"
}
}
},
"prop3": {
"date": {
"$date": "2021-09-14T14:50:37.303Z"
}
},
"prop1": "test1",
"_created_at": {
"$date": "2021-09-14T14:50:38.108Z"
},
"_updated_at": {
"$date": "2021-09-14T14:50:38.108Z"
}
}
prop2.test.date
is saved as JSON object instead of $date
object while prop3.date
is properly saved.
This breaks date queries
Steps to reproduce
- Create new object with below code
const myObj = new Parse.Object('Company3');
await myObj.save({
prop1: 'test1',
prop2: {
test: {
date: new Date()
}
},
prop3: {
date: new Date()
}
}, {useMasterKey: true});
- Observe different date types at different levels in mongoDB Compass
Actual Outcome
{
"_id": "5DTIqZcZv9fhbHu0qTZq",
"prop2": {
"test": {
"date": {
"__type": "Date",
"iso": "2021-09-14T14:50:37.303Z"
}
}
},
"prop3": {
"date": {
"$date": "2021-09-14T14:50:37.303Z"
}
},
"prop1": "test1",
"_created_at": {
"$date": "2021-09-14T14:50:38.108Z"
},
"_updated_at": {
"$date": "2021-09-14T14:50:38.108Z"
}
}
Expected Outcome
{
"_id": "5DTIqZcZv9fhbHu0qTZq",
"prop2": {
"test": {
"date": {
"$date": "2021-09-14T14:50:37.303Z"
}
}
},
"prop3": {
"date": {
"$date": "2021-09-14T14:50:37.303Z"
}
},
"prop1": "test1",
"_created_at": {
"$date": "2021-09-14T14:50:38.108Z"
},
"_updated_at": {
"$date": "2021-09-14T14:50:38.108Z"
}
}
Environment
Server
- Parse Server version:
4.10.3
- Operating system:
Mac OS
- Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc):
Local
Database
- System (MongoDB or Postgres):
MongoDB
- Database version:
4.4.4
- Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc):
Local
Client
- SDK (iOS, Android, JavaScript, PHP, Unity, etc):
Javascript
- SDK version:
3.3.0
Old issue related to this #6840