3 ms·
>Finally, writing inserts and updates as JSON is convoluted. What should be a fairly simple operation like: "atomic increment this nested value, or insert if va
by tiltowait 3y ago
>Finally, writing inserts and updates as JSON is convoluted. What should be a fairly simple operation like: "atomic increment this nested value, or insert if value is not there" was simply a disaster. For example, increment "api" by one, or insert "api":1 if necessary [...]
Maybe I'm missing something, but wouldn't `db.coll.update_one(search_query, {"$inc": {"visit_count.api": 1}})` do the trick?
Overall, I've been very happy with MongoDB (and their Atlas serverless offering). I would still default to recommending Postgres "by default", but for those use cases where MongoDB makes sense, it shines.
- juliusgeo 3y agoDisclaimer: I used to work for MongoDB. I think that MQL is very difficult to write because of its verbosity—it simply requires so much text. Even as someone who regularly wrote and debugged MQL queries, it is just so verbose, but essentially is just an AST structure and doesn’t need that much verbosity. I created a library that attempts to solve that friction, but I have no idea if it’s still being maintained by MongoDB: https://github.com/mongodb-labs/pymongoagg https://github.com/mongodb-labs/pymongoagg
- tiltowait 3y agoIt's definitely verbose, and working with it in Python is more annoying than in Javascript, due to the need to enclose all the operators in quotes. At the same time, I feel that the verbosity provides clarity, particularly in certain, more complex operations. Seems like your library was last updated in April, though just basic maintenance. It looks pretty interesting! I might play around with it next weekend.