How to query records that are created last N seconds, or N minutes?

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) }

But we do not have indexing for seconds or minutes. :confused:
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 and Aggregation


  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) {

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.

1 Like

jules and omurbekjk I’ve captured this as a limitation of dgraph and we’ll look in to it. We’ll keep you posted.

1 Like