I needed to remove several users from the RocketChat manually, i.e. not using the RC capabilities. In MondoDB I found these users, their direct messages and deleted them. There are no users anymore, there are no direct messages, everything is ok. But in the channel users list there is an incorrect number of users. That is, users 12 (plus switched off “rocket.cat”, but shown are 16 (as it was before, before removal).
How to fix this?
This is the number of users in the settings:
This is the number of users in the channel userlist:
This is why when ever asked, we would always recommend against touching the data directly in the database.
Users have subscriptions to channels you would have to remove their subscriptions as well. There is a number of other collections that would have orphaned data also.
Please use our api to delete users instead. Its much safer
In general, as administrator of ANY web application using a database - writes and deletes DIRECTLY on the database without the application’s knowledge is suicidal to the application’s health.
Many applications can become permanently damaged with a corrupted database in irrecoverable state.
Direct DB reads and copies are generally safe, but still should be kept to a “as-needed” minimum. On a heavily loaded system, even reads and copy can affect regular operations.