Contentful logo

Contentful Community

Querying for deleted entries

#1

Hi all,

I’m trying to get batchSize of entries that have been updated since some time from. So far, the following works for most of my cases:

  public List<CMAEntry> fetchBatch(ZonedDateTime from, Integer batchSize) {

    Map<String, String> query = new HashMap<>();

    query.put("sys.updatedAt[gt]",from.toLocalDateTime().toString());
    query.put("order","sys.updatedAt");
    query.put("limit", batchSize.toString());
    
    return client.entries().fetchAll(query).getItems();
  }

However, I’d also like this to include recently deleted entries. In my head, ‘deleting’ an entry is equivalent to ‘updating’ it to no longer exist. I’d love to know if there is a way I can modify this query so that recently deleted items are also included.

Does anyone have an idea? Does this make sense? I can expand more if required.

Thanks.

0 Likes

#2

Hi @sam.warner,

A possibility here would be to instead use the Sync API to fetch content that was recently deleted in your space.

You can find more information about this in here:

https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/synchronization

Here’s an implementation in JavaScript:

https://www.contentful.com/developers/docs/javascript/tutorials/using-the-sync-api-with-js/

0 Likes