Invalid Json Mongodb Search Documents

In MongoDB Atlas UI I can use the following [ {“xyz”: {$exists:true}} ]to return documents in a collection that contain the field “xyz”. But in make.com I get a the error, invalid JSON. Unexpected token $ in JSON at position 13

I’ve tried all sorts of combinations without luck. I’ve confirmed the scenario step search works with a blank {} entered in the query field.

Any help would be appreciated.

Hey @ryan_rockwood ,

In Make you have to use JSON format to send over the query. Try to use the following

{"xyz": {"$exists": true}}

Hope that works!

2 Likes

You nailed it. Thank you!

1 Like

OK, I’ve got a new one. Hope you can help. This query works perfectly in mongo and mongo compass:

{time: {$lt: ISODate(‘2022-11-10T18:09:23.000+00:00’)}}

the goal is to return documents created later than xyz. adjusted per your earlier suggestion, the query runs but no results:

{“time”: {“$lt”: ISODate(‘2022-11-10T18:09:23.000+00:00’)}}

I’ve tried everything I could possibly think of in regards to combinations without success. A screenshot I’ve included shows one of about 100 combos I tried.

However, a blank {} query does return results. Also, {“time”: “$exists”: true}} does return results. And if this post allows me to include a screenshot you will see an example. You may note Make.com shows the time field capitalized but I tested and that doesn’t work in a query. Also Make’s results show a different date format (time field is Date type) but I tried and that fails in queries too.

Hope you or someone can help!


Created a new post for this followup Help format MONGODB query in make

1 Like