Search for most recent

Seems like this should be more obvious to me but how do you return the most recent items based on the ‘created_at’ field. Not just sorting the results.

order = [{‘field_name’:‘created at’, ‘direction’:‘desc’}] does not seem to get me there.

Daniel

2 Likes

It looks like you might just be missing an underscore in your field name. Have a try with created_at instead.

Here’s an example where I’m pulling the last 5 event logs on my site:

sg.find("EventLogEntry", [], ['created_at'], order=[{'field_name':'created_at', 'direction':'desc'}], limit=5)

7 Likes