Describe the problem/error/question
Trying to do a Find query within my mongdb node and I’m not getting anything in retrun. If my query is just { } I get data.
What is the error message (if any)?
No errors, just empty retrun.
Please share your workflow
Share the output returned by the last node
Output is empty
[
{}
]
Information on your n8n setup
- n8n version:
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app):
- Operating system:
Hi,
Can you please correctly post your workflow?
Also, the query that you are trying to run, does it produce correct results with another tool (in other words did you validate your actual query)
Thanks
J.
It does within MongoDB Compass.
In Compass I have to remove the double quotes around the Created and $gte
inside my mongodb node
{
“Created”: {
“$gte”: “2025-01-05T12:09:43.447Z”
}
}
compass
{ Created: { $gte: ISODate(“2025-03-26T14:30:55.027+00:00”) } }
Yes, this form of the query works in Compass
{
Created: {
$gte: ISODate(“2025-03-26T14:30:55.027Z”)
}
}
This is what I have as a fixed query in my Mongodb node
{
“Created”: {
“$gte”: “2025-01-05T12:09:43.447Z”
}
}
this doesn’t work unless i remove the double quotes
Getting a mongodb query to match an exact date is a chore because of the way BSON stores the date value underneath. This thread explains some of it, but the answer for this is generally always to frame the value between some starting point (like the beginning of the day) and an ending point (like the beginning of the next day).
I set up a Fixed query with the following and I still don’t get any data returing.
{
“Created”: {
“$gte”: “2025-01-01T00:00:00Z”,
“$lt”: “2025-04-01T00:00:00Z”
}
}
Sorry. Missed that you were using a community node instead of the built in MongoDB node. The query syntax that ultimately works for both should be the same though. This thread might help. It doesn’t look simple and elegant, but that might be just how complicated it is to do this for MongoDB.
1 Like
Thank you for the link to the post, it worked.
I had to select Aggregate as the operating and update a few things.
Thank you again.