FgForrest / evitaDB

evitaDB is a specialized database with an easy-to-use API for e-commerce systems. It is a low-latency NoSQL in-memory engine that handles all the complex tasks that e-commerce systems have to deal with on a daily basis. evitaDB is expected to act as a fast secondary lookup/search index used by front stores.
https://evitadb.io
Other
61 stars 7 forks source link

Filter references without referenced objects (optionally) #603

Closed novoj closed 2 months ago

novoj commented 3 months ago

evitaDB supports eventual consistency - i.e. allows to have a reference to a not yet existing entity. This is due to the fact that evitaDB usually maintains a secondary index that is gradually updated according to changes in the primary database. This change propagation can't be done transactionally and there can be situations where entity A that references entity B is created first when B starts to exist in evitaDB and it is considered as all right situation.

But when the client queries the data, it usually doesn't want to consider the references to non-existent entities. Except for the situation when it does updates - then it needs to know about the existence of the reference to avoid sending unnecessary upsert mutations to the server.

evitaDB should support this scenario with a new requirement argument - let's call it io.evitadb.api.query.require.ManagedReferencesBehaviour#EXISTING, which would tell the evitaDB engine to filter out references to managed entities that do not yet exist in evitaDB.

This requirement must also handle situations where the target managed entity exists but doesn't satisfy the constraints. For example, the client reads the entity in a particular locale, and the referenced entity doesn't have that locale and therefore can't be returned.

novoj commented 2 months ago

We will not propagate this requirement to GraphQL API because it's adept for the directives which needs to be researched in different issue: https://github.com/FgForrest/evitaDB/issues/474