Query by distance and date with Pymongo [duplicate]

Query by distance and date with Pymongo [duplicate]

I know this is a very basic question, but I don't understand how to do this.

I know this is a very basic question, but I don't understand how to do this.

I'm using pymongo 3.6.1 in Python 3 and MongoDB 3.4.19. I'm trying to retrieve from the database the records lower than certain date, sorted by distance. By separate the functions are:

db[database].MIDAS_stations.find(
        {
            "loc": {
                "$near": {
                  "$geometry": {
                    "type": "Point",
                    "coordinates": coords
                  }
                }
              }
        }
    )

and

db[database].MIDAS_stations.find(
        {
          "Station start date": {
            "$gt": date1
          }
        }
    )

I have tried with aggregate instead of find, but I still haven't found the way to do this.

I know that there's something similar answered at MongoDB/PyMongo: Querying multiple criteria - unexpected results, but my question is different as it makes use of georeferenced data.

From MongoDB/PyMongo: Querying multiple criteria - unexpected results and https://stackoverflow.com/a/23577413/2313887 I think that the answer to this problem is:

db[database].MIDAS_stations.find(
    {            
        "loc": {
            "$near": {
                "$geometry": {
                    "type": "Point",
                    "coordinates": coords
                }
            }
        },
        "Station start date": {
                "$lt": date1
            }
    }
)

But I'm still uncertain if this is the right approach or if it is really querying for the nearest entries and then selecting only those with a date lower than date1.

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Learn MongoDB - MongoDB Tutorial for Beginners - Getting Started with MongoDB - Part 1/3

Learn MongoDB - MongoDB Tutorial for Beginners - Getting Started with MongoDB

Learn MongoDB - MongoDB Tutorial for Beginners - Getting Started with MongoDB - Part 2/3

Learn MongoDB - MongoDB Tutorial for Beginners - Getting Started with MongoDB

Learn MongoDB - MongoDB Tutorial for Beginners - Getting Started with MongoDB - Part 3/3

Learn MongoDB - MongoDB Tutorial for Beginners - Getting Started with MongoDB