Id Format

When storing entities in the database, it is crucial to ensure that each document has a unique identifier (id). This unique id serves as the primary key for the entity, allowing for efficient retrieval, updates, and prevention of duplicates.

Below are some recommended id values to consider when creating new entities.

  • Use transaction_hash and log_index

let Id =
    `${transaction.transaction_hash}-${log.log_index}`.toLowerCase();
  • Convert addresses in this format

let Id = from_address.toString().toLowerCase();

When creating and saving a new entity, if an entity with the same ID already exists, the properties of the new entity are always preferred during the merge process. This means that the existing entity will be updated with the values from the new entity.

Last updated