You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to send a mongoDB query using { "$date" : "2024-11-08T00:00:00Z" }, but it is not working; if I put the query on Mongo compass, it works fine.
To Reproduce
Create a query like this
aggregate or find
[{ "$match": { "created_at": { "$gte": { "$date": "2020-01-01T08:23:14.000Z" } } } }, { "$limit": 10 }]
Expected behavior
returning the expected data; the node does not return anything.
Operating System
n8n cloud
n8n Version
1.67.1
Node.js Version
NA
Database
SQLite (default)
Execution mode
main (default)
The text was updated successfully, but these errors were encountered:
I encountered the same use case. There is a work around with $expr and $toDate.
In the code example I provide, please keep in mind that in my workflows, the documentDate field can be a JSDate or a string.
Here is an example of code that I use to fetch claims between two dates:
{
"anyOtherField": <any value or expr>,
"$expr": { "$and": [
{ "$lte": ["$claimPeriodStartDate", { "$toDate": "{{ $json.documentDate instanceof Date ? $json.documentDate.toISOString() : $json.documentDate }}"}]},
{"$gte": ["$claimPeriodEndDate", { "$toDate": "{{ $json.documentDate instanceof Date ? $json.documentDate.toISOString() : $json.documentDate }}"}]}
}
If you check the source code, you'll see that the query is parsed as a strict JSON to reconstruct an object, it's not using the strict JSON mode therefore no $date or $oid.
I've had to modify my local version to replace $oid and $date by function calls for inserts.
Bug Description
I am trying to send a mongoDB query using { "$date" : "2024-11-08T00:00:00Z" }, but it is not working; if I put the query on Mongo compass, it works fine.
To Reproduce
Create a query like this
aggregate or find
[{ "$match": { "created_at": { "$gte": { "$date": "2020-01-01T08:23:14.000Z" } } } }, { "$limit": 10 }]
Expected behavior
returning the expected data; the node does not return anything.
Operating System
n8n cloud
n8n Version
1.67.1
Node.js Version
NA
Database
SQLite (default)
Execution mode
main (default)
The text was updated successfully, but these errors were encountered: