Objects have user_id but not user() when the user is deleted

I have several users and also several objects called ‘learner’, and each learner optionally belongs-to a user.
When I delete a user, I expect the relationship to be broken. However, it seems that a learner which belongs-to a user, no longer has access to user() but still has user_id?
Is this intended behaviour? Do I need to go through all the relationships myself and remove them?

This is expected behavior. A belongs-to field is just a guid that points at a specific object of another model. If you want to ensure that the user still exists, you could update your code to check user() instead of user_id. Alternatively you could write a pretty simple CloudCode task that loops through your learner objects checking for user() and nulling the field if it does not exist.

1 Like