Open tinchodias opened 6 years ago
What is the current status?
I still have the same question. Do you have any opinion? I can create PR this week.
Update: Now that I worked on the MongoClient (in #68), I suspect MongoDatabase and MongoCollection fit much better at the level of this SDAM package instead of the more lower-level Mongo model.
Can this be closed?
If you see in current master, there are at least 8 cases of this pattern:
where the API of MongoCollection correctly exposes a behavior of a collection in mongodb, and always the implementations is just "forwarding" (may be not the correct word) the message to the MongoDatabase adding some parameter.
Another example, extended:
as you can see, the MongoDatabase also forwards the message to root (an instance of Mongo).
This is not only a pattern that means annoying code... IMHO, the fact that a database contains collections doesn't imply that MongoDatabase should be a kind of facade or mediator between MongoCollection and Mongo. I think MongoCollection could send messages directly yo Mongo.
Also, MongoDatabase and MongoCollection belong to a same abstraction level. Only Mongo is more low-level stuff because it reads and writes to the socket that connects to mongodb.
Finally, a proposal to fix it: let MongoCollection know the root (Mongo instance) and not only the MongoDatabase. This: