From acdd4366ccb9f07e5f5d827aa2d519c568719e35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Wed, 11 Sep 2024 10:55:28 +0200 Subject: [PATCH 1/2] Add a MongoCollection.find(FindOptions) overload. Avoids accidental misuse of the API, erroneously treating the FindOptions value as the query. --- mongodb/vibe/db/mongo/collection.d | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mongodb/vibe/db/mongo/collection.d b/mongodb/vibe/db/mongo/collection.d index 16dab6816..92b4e9a56 100644 --- a/mongodb/vibe/db/mongo/collection.d +++ b/mongodb/vibe/db/mongo/collection.d @@ -519,6 +519,8 @@ struct MongoCollection { - $(LREF findOne) */ MongoCursor!R find(R = Bson)() { return find!R(Bson.emptyObject, FindOptions.init); } + /// ditto + MongoCursor!R find(R = Bson)(FindOptions options) { return find!R(Bson.emptyObject, options); } /// @safe unittest { From 2e298d16da36d2e21d08c086e71163ee682402e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Wed, 11 Sep 2024 13:11:50 +0200 Subject: [PATCH 2/2] Fix compile error on old versions of DMD. --- examples/bench-mongodb/source/app.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/bench-mongodb/source/app.d b/examples/bench-mongodb/source/app.d index 312320692..c7a1c11ac 100644 --- a/examples/bench-mongodb/source/app.d +++ b/examples/bench-mongodb/source/app.d @@ -37,8 +37,8 @@ void main() } logInfo("Running queries..."); + static struct Q { int i; } auto dur_query = runTimed({ - struct Q { int i; } foreach (i; 0 .. nqueries) { auto res = coll.find!Item(Q(5)); res.front;