Matt LuoM
Convex Community2y ago
21 replies
Matt Luo

`.last()`

Regarding query functions, I noticed there is not a method like last() that would be the opposite of first()
https://docs.convex.dev/api/interfaces/server.Query#first
To get the last document, do you typically add an index to that column and add something like this to the query: .order("desc").first()?
I ask because there doesn't seem to be native functionality to add a unique constraint on a column. So simply doing a last() method may be a hacky way to quickly get coding with a predictable handling of duplicates.
Was this page helpful?