I did little research before asking this question here. But I could not figure it out how to write correct query using variables
and math, since
functions.
You have any timestamp that is saved in your nodes
I would like to know about this as well… does any one have a solution?
The only way would be to use “DateTime Indices” along with { has (created_at)
}
https://docs.dgraph.io/query-language/#indexing
But we do not have indexing for seconds or minutes.
I believe this has already been discussed here some time while ago. I remember it was not possible until then.
DateTime writes in seconds (in RFC3339 format), however the indexing for this gets expensive.
This would have to be resolved in your app.
In the example below with Has, you could get (globally) at least in the last hour.
And you can use with pagination https://docs.dgraph.io/query-language/#pagination and Aggregation https://docs.dgraph.io/query-language/#aggregation
e.g:
{
lastOnes as var(func:has (created_at)) #You could add a filter here or in the block "myRecords"
myRecords(func: uid(lastOnes), orderdesc: created_at) {
uid
name@en
}
}
But nothing prevents a magician from appearing with a good idea xD
This would not be the first time that some charms would happen in this community.
jules and omurbekjk I’ve captured this as a limitation of dgraph and we’ll look in to it. We’ll keep you posted.