I have a user collection and I have an API thats delete the user. However, I use the user as a reference in other collections like in Posts has a userId reference, visitRequests also.
Is there a proper way to do this ? or should I just in each collection do a specific query like this ?.
await User.findOneAndDelete({ _id: id });
await visitRequestModel.findOneAndDelete(
{_userId: id},
);
...
Also I want for example to change the status in Posts collection instead of deleting it.
And, can this be done in aggregate method instead ?