if I take out the “time” field it returns exactly what I expect–all matches for serial and chamber. But every format I try with the “time” field just returns nothing. I’ve tried everything I can think of with the $gt section but can’t land on one that works. any ideas?
This is a difficult question as I don’t know much about your MongoDB setup. If you use the query you sent with a hardcoded date, rather than ISODate('{{data.body.startDate}}'), do you get any results?
Also, it looks like you’ve got a little bit of incorrect JSON. With your query, you are trying to compare time to the string "{$gt: ISODate(’{{data.body.startDate}}’)}” which will not work. Your query should look like this:
thanks Heath. I’m going to give those a try. So far the first bit of code you gave me fixing my JSON error is giving me an error in the MongoDB query field.
if I put a hardcoded date into my original query nothing changes, but it makes sense if you are saying I’m JSON was formatted incorrectly. but I can’t get either of your suggestions to work.
my mongodb setup is pretty simple. here’s the form of one of the records:
If I use Mongo Compass or even am logged into mongodb.com looking at my collection, I can use the following filter to get the results I expect: {“time”: {"$gt": ISODate(‘2021-07-17’)}}
sorry to bother, but I still can’t get this to work. I tried copying and pasting your suggestions in just to see if it would give me progress I could build on, but your first suggestion looks like this when I put it into the mongoDB query argument box:
thanks Heath! definitely cleared up the json error in the module, but isn’t returning anything from mongo. I just can’t figure out why it’s not. the same query directly in mongo compass returns exactly what I want. is there a way to see the behind the scenes of what’s happening when the endpoint is hit in terms of how it’s requesting from mongo? the only different in mongo Compass is that it’s in a single line, but I’ve tried the “string template”. I’ve got the paths set for the response from mongo and the error if there is one. but with your example there is no response from mongo and no error.
I’ll try it again now. before it didn’t return anything, but I’ll give it a shot. data.body.startDate is a date like format in my payload : “2021-07-17” for example. should the ‘x’ in the formatDate handlebar be x or should I try putting my format (YYYY-MM-DD) in for x?
still no results from mongo. if i try to put in ‘YYYY-MM-DD’ or that without the single quotes or that with double quotes the block errors and I can’t save. with ‘x’ it saves, but returns no results. no errors being returned either. I expect 23 records from mongo with what the data.body payload contains.
genius. thank you Heath. I never would have gotten to the momentjs format. i thought I tried every iteration of time, date, time–>date, everything. thank you so much for your help as always.