Skip to content

Nested dates are saved as two different types in MongoDB Atlas. Breaks sort queries. #6840

Closed
@kekami

Description

@kekami

New Issue Checklist

Issue Description

We've discovered an issue where Dates are saved as two different types in MongoDB Atlas. Everything looks fine on the JS side, however, the issue manifests itself on certain queries.

// Version 1
id: "nIcSRZ03ZB"
feedLastRead: Object
  e5i0xwOBJG: Object
    __type: "Date"
    iso: "2020-06-02T12:30:52.730Z"
// Version 2
_id: "l3pyBDqBu5"
feedLastRead: Object
  e5i0xwOBJG: 2020-06-02T06:56:12.944+00:00

Steps to reproduce

Save a Date in an object e.g. someObject.save({ feedLastRead: { userId: new Date() }).

Actual Outcome

When doing a sort query on the nested Date object e.g.

someObject.query().descending('feedLastRead.e5i0xwOBJG').find();

The returned objects wont be sorted correctly, but instead in two groups. e.g.

Version 1
Version 1
Version 1
Version 1
Version 2
Version 2
Version 2
Version 2
Version 2

Expected Outcome

That the return object will be sorted based on date regardless of the type of the date.

Environment

Server

  • Parse Server version: "parse-server": "^4.3.0"
  • Operating system: MacOS Catalina 10.15.6
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): Local & Heroku

Database

  • System (MongoDB or Postgres): MongoDB
  • Database version: 3.6.18
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): MongoDB Atlas

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): Javascript
  • SDK version: "parse": "^2.15.0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions