Search code examples
javascriptnormalizr

Normalizr - for what purpose "result" prop is placed in the output?


So, typically, when we create normalized entity shape by using func normalize(originalData, someShape) - we gets an object on the output with form like:

{ entities: {...}, result: main_entities_id }

And question is - why we need the second result prop in the normalized object? What is the reason to place it here by creators of normalizr?

Thanks


Solution

  • The result is the normalized form of the input data.

    For example:

    • If your input data is a single entity, the result will be the ID of that entity.
    • If your input data has shape [ entity1, entity2 ], the result will be an array of the IDs for those entities, [ '1', '2' ].