At various points in the code, users are identified using their email, or their associated user id in the database.
This makes things confusing in the code: foreign keys typically rely on the user id rather than the email, but other logic will use the email in WHERE statements. Sometimes my code has to translate from the email to the user id to make certain logic work.
It'd be better if we could enforce greater consistency.
Requirements
Modify logic so that user id is the primary point of reference.
Where the user email is present prior to a query requiring user identification, run a separate query that retrieves the user id from the user email.
Alternatively (or in conjunction), incorporate use of the new DatabaseClient.UserIdentifier class, which would store both the user id and the user email.
ANOTHER option is to have the user identifier object be generated by the API key or JWT logic and pass that into the body of the function. This would also require the JWT logic to combine both the user email and id through something like json.loads (whereas currently the user email alone is provided).
Tests
Some tests may have to be modified depending on whether the user email or the user id is provided in the functionality.
Aside from the above cases, testing logic should remain the same.
Docs
Unlikely to be applicable.
Open questions
Translating user id to user email or back may create additional overhead. This overhead is likely to be relatively marginal, but it's still worth keeping in mind through all of this.
Context
WHERE
statements. Sometimes my code has to translate from the email to the user id to make certain logic work.Requirements
DatabaseClient.UserIdentifier
class, which would store both the user id and the user email.json.loads
(whereas currently the user email alone is provided).Tests
Docs
Open questions