Fetch latest record / entry in Deta base? #344
-
|
Quick question: How would I retrieve the latest entry/record in the Deta Base? Based on a date is not possible, right? Or based on the key? Sorry for being fairly new to this! Thanks so much for helping me and building this awesome tool! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
|
Hi @TychoLex42 , Base will return items using If you simply use So what you can do, is use keys that that get smaller as unix time gets larger. So if you store items with the key scheme Hope that helps! |
Beta Was this translation helpful? Give feedback.

Hi @TychoLex42 , Base will return items using
fetchin ascending order, so you can indeed do this, using a variation ofunix timestampsas keys.If you simply use
unix timestampsas keys, this will do the opposite of what you want -- as the first item you fetch will be the oldest item (smallest time stamp).So what you can do, is use keys that that get smaller as unix time gets larger. So if you store items with the key scheme
some really big number-unix time stamp, the first item you get from a fetch will be the most recent.Hope that helps!