Filter Events() using a time range

Hello,

I’m trying to find a way to filter Events() using a time range but I don’t know what are the good options for it… :thinking:

Thanks.

@Bruno_Quaresma1

You will not be able to use Range on Events but below is an example to achieve the same with the after cursor.

Distinct(Map(
  Paginate(Events(Match(Index("emp_ts"))), {after:1587067784760000, size: 1024}), 
  indexEvent => Select(['data', 0], Paginate(Events(Select(['document'], indexEvent)), {size: 1, after: Select(['ts'], indexEvent)}), false)
))

This example gets all the Events on the Index(“emp_ts”) created after:1587067784760000 and for each of those, it gets a corresponding Event on the Document.

Index definition

> CreateIndex(
{
name: "emp_ts",
source: Collection("emp"),
values: [{field: ["ts"]}]
}
);

Please let us know if this helps.

1 Like

@Jay-Fauna is that possible to get all the events from a specific collection? Like, I would like to get all the events from the “users” collection.

@Bruno_Quaresma1 To be clear, you want all the Events on all Documents in the Users Collection? If so, Paginate(Events(Match(Index("emp_ts"))), { size: 100000}) gets all the events on the Index(“emp_ts”) which then corresponds to an event on each Document.

Another way is to loop through the Documents in the Collection('users) using Foreach and Get Events for each Document.

1 Like