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.

jquery mongodb

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

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

What is new features in Javascript ES2020 ECMAScript 2020

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Random Password Generator Online

HTML Color Picker online | HEX Color Picker | RGB Color Picker

MongoDB Database and java applications

Enroll for free demo to acquire the best knowledge on the schema-less database from live industry experts through MongoDB training

Hire Dedicated Jquery Developer

Are You Looking To Hire a jQuery Programmer? **[HourlyDeveloper.io](https://hourlydeveloper.io/ "HourlyDeveloper.io")**, a leading jQuery application development company, can help you build interactive front-end solutions to leapfrog the digital...

Which is the Best MongoDB GUI?

Our MongoDB Online Training provide you to learn about MongoDB strategies with realty. Our MongoDB Online Training also includes live sessions, live Projects, and much

Improve the MongoDB Aggregation Framework

Our MongoDB Online Training provide you to learn about MongoDB strategies with realty. Our MongoDB Online Training also includes live sessions, live Projects, and much

MongoDB – Database, Collection, and Document

Our MongoDB Online Training provide you to learn about MongoDB strategies with realty. Our MongoDB Online Training also includes live sessions, live Projects, and much