You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you see in current master, there are at least 8 cases of this pattern:
MongoCollection>>
commandInsert: newDictionary writeConcern: aConcern
"Insert using Mongo command. Answer the output of the command.
See more on https://docs.mongodb.com/manual/reference/command/insert/"
^database commandInsert: newDictionary collection: name writeConcern: aConcern
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.
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:
MongoCollection>>
insert: aCollection
root insert: aCollection collection: self database name , '.' , self name
The text was updated successfully, but these errors were encountered:
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.
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:
The text was updated successfully, but these errors were encountered: