Skip to content

Commit

Permalink
add mongodb.replaceOne overload taking ReplaceOptions
Browse files Browse the repository at this point in the history
was probably accidental that we allowed UpdateOptions in there

Now we just allow both since the structs are almost equivalent
  • Loading branch information
WebFreak001 committed Feb 5, 2024
1 parent 6d717c9 commit 5868c6c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mongodb/vibe/db/mongo/collection.d
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,17 @@ struct MongoCollection {
Standards: $(LINK https://www.mongodb.com/docs/manual/reference/command/update/)
*/
UpdateResult replaceOne(T, U)(T filter, U replacement, ReplaceOptions options = ReplaceOptions.init)
@safe {
UpdateOptions uoptions;
static foreach (i, val; options.tupleof)
uoptions.tupleof[i] = val;
Bson opts = Bson.emptyObject;
opts["multi"] = Bson(false);
return updateImpl([filter], [replacement], [opts], uoptions, true, false);
}

/// ditto
UpdateResult replaceOne(T, U)(T filter, U replacement, UpdateOptions options = UpdateOptions.init)
@safe {
Bson opts = Bson.emptyObject;
Expand Down

0 comments on commit 5868c6c

Please sign in to comment.