You can select the Operation Type as “Run Database Command” and then enter the command, as shown in the image.
{
find: “Collection”,
sort: { Version : -1 }
}
if i want to filter by other fields, How i can find?
“HotelId” : “{{hotel}}”,
This is correct, right?
{
“find”: “Collection”,
“filter”: {
“HotelId”: “{{hotel}}”
},
“sort”: {
“Version”: -1
}
}
Your command is correct if you want to query the “Collection” for documents where “HotelId” equals “{{hotel}}” and sort them by “Version” in descending order.
So, I try to this but it no result return:
{
“find”: “Collection”,
“filter”: {
“HotelId”: “{{hotel}}”,
“CheckInDate”: “{{date}}”
},
“sort”: {
“Version”: -1
}
}
I tried to do the same, but it didn’t work
{
“find”: “Collection”,
“filter”: {
“HotelId”: “{{hotel}}”
// “CheckInDate”: “{{date}}”
,
“CheckInDate”: {
“$gte”: “2025-05-28T00:00:00.000Z”,
“$lt”: “2025-05-29T00:00:00.000Z”
}
},
“sort”: {
“Version”: -1
}
}
on the mongo found but on API Dog not found
The command syntax is correct. If no results are returned, it might be due to no matching data. I noticed you’re using variables - please verify they are properly replaced with actual values. You can add a pre-request script to check the variable values:
console.log(pm.variables.get("hotel"));
console.log(pm.variables.get("date"));
It have values
of Both
You can also open the “Console Log” and provide me with some screenshots of the database command and console results.
if filter by only hotel it return results
but add checkin date filter, it not work
We currently haven’t fully supported the default MongoDB date object format. I’ve reported this issue to our technical team, and we’ll work on compatibility improvements in future updates.
Ok, thank you.