In MongoDB, the $rtrim
aggregation pipeline operator removes whitespace from the end of a string. This includes the null character.
It can also remove any character specified. For example, you could use it to remove all periods (.
), exclamation marks (!
), etc from the end of a string.