Search code examples
javers

Javers QueryBuilder Pagination Support


UseCase :: How to write query using javers query builder that can support pagination while fetching audit's logs for api's.


Solution

  • One possible way to write query is by using skip() and limit().

    @Service
    public class AuditService {
    
        @Autowired
        Javers javer;
    
        public List<Change> fetchAudits(String auditer,Integer offset,Integer limit) {
            return javer.findChanges(QueryBuilder.anyDomainObject().byAuthor(auditer).skip(offset).limit(limit).build());
        }
    
    }