A
A
Alex Kizyma2020-04-25 18:34:31
Node.js
Alex Kizyma, 2020-04-25 18:34:31

How can I get tours by timestamp and show everyone who was added after the timestamp?

{
    "status": "success",
    "results": 3,
    "data": {
        "tours": [
            {
                "rating": 4.2,
                "_id": "5ea456e30c29bb7b228aa223",
                "name": "Test tour",
                "price": 100,
                "createdAt": "2020-04-25T15:27:31.613Z",
                "updatedAt": "2020-04-25T15:27:31.613Z",
                "__v": 0
            },
            {
                "rating": 4.2,
                "_id": "5ea456e80c29bb7b228aa225",
                "name": "Test tour 2",
                "price": 100,
                "createdAt": "2020-04-25T15:27:36.704Z",
                "updatedAt": "2020-04-25T15:27:36.704Z",
                "__v": 0
            },
            {
                "rating": 4.2,
                "_id": "5ea456f00c29bb7b228aa227",
                "name": "Test tour 3",
                "price": 100,
                "createdAt": "2020-04-25T15:27:44.807Z",
                "updatedAt": "2020-04-25T15:27:44.807Z",
                "__v": 0
            }
        ]
    }
}


I get it by ID like this But how can I get the tour by timestamp and show all which ones are added after the timestamp?
const tour = await Tour.findById(req.params.id)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question