This repository was archived by the owner on Aug 7, 2023. It is now read-only.
Repository navigation
|
If I use time-sortable ULIDs as keys in Deta Base, will be able to get all items before or after a specific time by using the greater than/less than operator queries? Does Deta Base support such string comparisons? |
Answered by
abdelhai
Jun 2, 2022
Replies: 2 comments 1 reply
|
yes, check our queries page: https://docs.deta.sh/docs/base/queries |
1 reply
Answer selected by
theseyan
|
We can sort records by any column If we pull all records from the database first and sort them using vanilla JavaScript sort() method for sorting array of objects. let result = await req.mydb.posts.fetch()
let allItems = result.items
while(result.last){
result = await req.mydb.posts.fetch({}, {last: result.last})
allItems = allItems.concat(result.items)
}
allItems.sort((a, b) => {
let da = new Date(a.date)
let db = new Date(b.date)
return db - da
})
const posts = allItems.slice(0, 9) |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yes, check our queries page: https://docs.deta.sh/docs/base/queries
and at the bottom where we have an example and list the limitations: https://docs.deta.sh/docs/base/queries#querying-keys