We have been using MongoDB's mechanism to generate system IDs on insert. This is not ideal because it requires us to execute operations in a certain order (e.g. we don't know the system ID until it is actually created in the DB). We also had to use None as a hacky placeholder for system_id before the record is inserted into the DB (it is also not type-correct). This is error-prone because if the developer doesn't know this context, they may access system_id before it holds the actual value.
This PR fixes this issue by pre-generating the id for the system so system_id is always accessible.
We have been using MongoDB's mechanism to generate system IDs on insert. This is not ideal because it requires us to execute operations in a certain order (e.g. we don't know the system ID until it is actually created in the DB). We also had to use
None
as a hacky placeholder forsystem_id
before the record is inserted into the DB (it is also not type-correct). This is error-prone because if the developer doesn't know this context, they may accesssystem_id
before it holds the actual value.This PR fixes this issue by pre-generating the id for the system so
system_id
is always accessible.