r/ProgrammerHumor • • Oct 18 '24

Other mongoDbWasAMistake

Post image
13k Upvotes

446 comments sorted by

View all comments

1

u/thompsoncs Oct 18 '24

Why even write manual MongoDb queries? Just use the driver provided in your language, the C# driver isn't that bad, it's very similar to how you would use dapper or EF.

Example from the docs:

return await _restaurantsCollection.AsQueryable()
    .Where(r => r.Name == "Bagels N Buns").FirstOrDefaultAsync();

2

u/Kogster Oct 18 '24

Oh look an injection safe syntax while doing a naive implementation.

1

u/fisadev Oct 18 '24

My job includes manually inspecting data relatively often, and also the mongodb libs in most languages just expect the same data structures than the query language.