question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a method to fetch Snapshots or Changes by (multiple) local ID without the need of TypeName or Class

See original GitHub issue

Requirement I am working on a project that involves Entities (saved in Mongo) to be associated with IDs as properties. For example, A User has addressId that references Address being a separate Entity since it follows a separate lifecycle. All the changes to these entities are being audited using Javers in a central repository (through a Microservice). As a part of the functionality, I need to display consolidated audit logs on a Web UI. Trouble is the fetching of the audits for multiple entities of different types. Since the methods to build a JqlQuery take either a TypeName or a Class along with the instance IDs, the clients always need to have more knowledge than they should have to fetch the logs.

Describe the solution you’d like Since our entities have unique IDs (UUID), there should be no need of supplying the TypeName or the entity Class to fetch the CdoSnapshots or the Changes since the clients have access to the main entity and the IDs of the associated entities that they can use directly. At the same time, there could be a method that would accept multiple instanceIds without the Class or TypeName. Either this or there should be scope to supply a custom FilterDefinition to the QueryBuilder to allow defining a custom matcher where we could use different criteria for matching a CdoSnapshot or Changes.

Describe alternatives you’ve considered One of the alternatives we have right now is to annotate each and every entity with a @TypeName across microservices and the client knowing all these TypeName for each of the properties of the main entity to be able to fetch the audits. This is a huge overkill. Even with that, there is no way of fetching the audits for multiple entities and instanceIds together limited by pages.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nishkarshcommented, Jul 27, 2020

Hey @bartoszwalacik! Thanks for the response. I will spend some time in verifying if the existing indexes would work with this. I will also discuss the changes that might be required before proceeding.

0reactions
michaelkrogcommented, Nov 4, 2022

I second this.

In our case we have a Spring boot based library that can be used in multiple services. One of the things it supplies is Javers - but being an external library it won’t know anything about all the entities that are persisted in the application it is used in.

But what we do have is unique ids that’s is prefixed with the data type, fx. a Contact could have the id cont-1234, Note could have note-1234. In other words our id’s are unique AND carry the type in them.

Therefore it could be awesome to be able to simply get its changes by QueryBuilder.byInstanceId("cont-1234").

What we need to do now is to add @TypeName to all entities with the type part of our id(fx. @TypeName("cont")) and then retrieve them by extracting the type part from the id before resolving:

var type = id.split("-")[0]; // Get 'cont' from 'cont-1234'
var query = QueryBuilder.byInstanceId(id, type).build();
Read more comments on GitHub >

github_iconTop Results From Across the Web

Get realtime updates with Cloud Firestore - Firebase
Events for local changes; Events for metadata changes; Listen to multiple documents in a collection; View changes between snapshots; Detach a listener ...
Read more >
JQL (JaVers Query Language) examples
Data history can be fetched from JaversRepository using javers.find*() methods in one of three views: Shadows, Changes, and Snapshots.
Read more >
The choice between typename and class - Marius Bancila's Blog
First, consider there is another class template that has two type parameters, as shown in the following snippet. template <typename T, ...
Read more >
snapshot | Liquibase Docs
snapshot. The snapshot command captures the current state of the URL database, which is the target database. The snapshot command has two modes:....
Read more >
Metric and Snapshot API - AppDynamics Documentation
This page describes the Controller Metrics and Events API methods that allow you to retrieve information on metric data and various types of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found