stijnsanders / TMongoWire

Delphi MongoDB driver
MIT License
102 stars 37 forks source link

[wish] Insert Update and Delete should be functions #46

Closed mariocarro closed 2 years ago

mariocarro commented 6 years ago

The result of the RunCommand fc which is used to implement Insert, Update and Delete contains useful information (like the number of modified documents, etc), but is currently discarded. That information could be made available to the user, making Insert Update and Delete into functions which return the result of the call to RunCommand. (edit: contains -> returns) (edit: undone, the original was ok).

stijnsanders commented 6 years ago

I agree, it's a good proposal and easy to do, but specifically with jsonDoc, in most cases where you process a series of similar operations, there's some advantage in (re)using a single IJSONDocument instance and Reset and Parse to re-use the allocated memory for the same keys.

So instead of a function returning the RunCommand's result, I'm also considering to have a third parameter to the procedures where you pass an IJSONDocument instance to use with the RunCommand...

I'll keep you posted when I get some time available to look into this.

mariocarro commented 6 years ago

Another possibility is to add a field to the class (accessible as a public read-only property) to hold the return value of the last call to RunCommand (or Insert/Update/Delete). This also allows to (re)use a single IJSONDocument instance as you suggest.

stijnsanders commented 6 years ago

For now I've done the functions with IJSONDocument's from the RunCommand's. See my most recent commit.

stijnsanders commented 2 years ago

Apparently a lot changed with MongoDB 5 and 6 (and I got a little out of touch), but I see insert/update/delete are functions as you suggested, so I'll close this issue. Also — especially with the new options available now that everything goes over an OP_MSG — you're free to do everything yourself with TMongoWire's Msg method just like the other methods do.