Skip to content

aggregate geoNear with filter on date field not working #6539

Closed
@mtrezza

Description

@mtrezza

Issue Description

An aggregate query with $geoNear stage with a query parameter on a date field does not return any results.

Steps to reproduce

This example works fine in mongo shell:

db.MyClass.aggregate([
{
    $geoNear: {
        'near': {
            'type': 'Point',
            'coordinates': [21.5, 4.1]
        },
        'key': 'location',
        'spherical': true,
        'distanceField': 'dist',
        'includeLocs': 'loc',
        'query': {
            'myDateField': {
                '$gte': new Date("2019-03-26T18:18:02.076Z")
            }
        }
    }
}])

This does not work in cloud code:

const date = new Date('2019-03-26T18:18:02.076Z');
const query = new Parse.Query("MyClass");
const pipeline = [
    {
        'geoNear': {
            'near': {
                'type': 'Point',
                'coordinates': [21.5, 4.1]
            },
            'key': 'location',
            'spherical': true,
            'distanceField': 'dist',
            'includeLocs': 'loc',
            'query': {
                'myDateField': {
                    '$gte': date
                }
            }
        }
    }
];

let results = await query.aggregate(pipeline);
  • The issue is only the query filter. Without the query parameter, the query returns the expected results.
  • Also, with filter fields other than the myDateField, the query returns the expected results.

Expected Results

The cloud code query should return the same results as the mongo shell query.

Actual Outcome

The cloud code query returns no results.

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 4.1.0
    • Operating System: -
    • Hardware: -
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): -
  • Database

    • MongoDB version: 4.2.3
    • Storage engine: WT
    • Hardware: -
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): -

Logs/Trace

verbose: REQUEST for [GET] /parse/aggregate/MyClass: {
  "pipeline": [
    {
      "geoNear": {
        "near": {
          "type": "Point",
          "coordinates": [
            21.5,
            4.1
          ]
        },
        "key": "location",
        "spherical": true,
        "distanceField": "dist",
        "includeLocs": "loc",
        "query": {
          "myDateField": {
            "$gte": "2019-03-26T18:18:02.076Z"
          }
        }
      }
    }
  ]

verbose: RESPONSE from [GET] /parse/aggregate/MyClass: {
  "response": {
    "results": []
  }

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