The database driver for MongoDB needs to override the class Drupal\Core\Entity\Sql\SqlContentEntityStorage. MongoDB does document/JSON storage instead of relational database storage. A number of core entities are overriding that class. The problem for the database driver for MongoDB is that it then also needs to override the methods in those entity specific classes too. It also needs to duplicate the code inside those classes too. Duplicating code is wrong.
Another problem is that the code in those classes that are overriding Drupal\Core\Entity\Sql\SqlContentEntityStorage is NOT extending what the base class is doing. The extra code can easily being moved to another class/service.
Create for each of the entities that are overriding the class Drupal\Core\Entity\Sql\SqlContentEntityStorage and are NOT related to that class, a new repository and move the code in the overriding classes to the new repository. Deprecate the old override classes.
The following entities have an override for the class Drupal\Core\Entity\Sql\SqlContentEntityStorage:
- Comment
- File
- Media
- MenuLinkContent
- Node
- PathAlias
- Term
- User