Query with filter on block_timestamp only returns to earliest createdAt

Hello, please correct me if I’m doing something wrong.

If I run the following query without filtering the date, I can retrieve all the results I’m looking for.

const query = new Moralis.Query(mptT)
    .limit(1000000)
    .select("block_timestamp")
    .equalTo("to", factory.toLowerCase());

  const results = await query.find();
  console.log("Request took:", new Date() - start, "ms");
  console.log("retrieved:", results.length);

  let date = [];

  for (let i = 0; i < results.length; i++) {
    const object = results[i];
    date.push(object.get("block_timestamp"));

  }

  console.log(new Date(Math.max.apply(null, date)));
  console.log(new Date(Math.min.apply(null, date)));


};


results : 

Request took: 3949 ms
retrieved: 16652
2021-11-20T11:16:05.000Z
2021-10-18T15:03:36.000Z

As you can see, the earliest transaction returns the 18 of October 2021.

However, if I run de same query with a filter .greaterThan(“block_timestamp”, new Date(“2021-10-01”));

const query = new Moralis.Query(mptT)
    .limit(1000000)
    .select("block_timestamp")
    .equalTo("to", factory.toLowerCase())
    .greaterThan("block_timestamp", new Date("2021-10-01"));

  const results = await query.find();
  console.log("Request took:", new Date() - start, "ms");
  console.log("retrieved:", results.length);

  let date = [];

  for (let i = 0; i < results.length; i++) {
    const object = results[i];
    date.push(object.get("block_timestamp"));

  }

  console.log(new Date(Math.max.apply(null, date)));
  console.log(new Date(Math.min.apply(null, date)));


};


results : 

Request took: 1661 ms
retrieved: 1957
2021-11-20T11:16:26.000Z
2021-11-17T01:01:48.000Z

I would expect to find the same results as my first query, however, as you can see, I only retrieve a part of them.

It’s interesting to note that on the second query, the earliest entry I retrieve is when I started the event sync. It seems that any block_timestamp less than the createdAt aren’t retrieved.

it looks like this worked for me in the past: Querying with block_timestsamp

do you know how to connect directly to mongo db to see how that block_timestamp looks like directly in mongo db?

I’ve seen that post earlier and tried it, however, my earliest entry in createdAt is the 17 of November (when I started the event Sync ) while the earliest block timestamp is 18 of October. The contract was running for almost a month before I started the sync.

I haven’t looked in MongoDB, however, this is how it looks like on Moralis dashboard dasboardView|690x260

I’ll try to connect directly to mongoDB