So was using Mongodb for a side project and it was an interesting experience.
Below are some notes in form a cheat sheet (helps me memorize everything)
See conclusion at the bottom but the TLDR is
really enjoyed working with mongo would use again but there are risks from structured side and user defined functions.
Mongo to SQL Mapping:
Mongo <—> SQL
Collection <—> Table
field <—> column
$lookup <—> table joins
$match <—> WHERE
$group <—> GROUP BY
$match <—> HAVING
$sort <—> ORDER BY
$limit <—> LIMIT
$sum <—> SUM()
$sum <—> COUNT()
The gt and lt is greater than and lesss than filters. As listed in table at top $match is the “where” and “having” filters
A really imporant note is that function names need to be unique across all databases which you can imagine can cause issues.
Also the eval method used by python and mongo to execute functions looks like it will be removed in the future. The work around is to same complex queries in program instead a function which isnt going to be fun.
The config file for mongo is in
The important one to note is the small log file setting. As the logging will fill up machine really quick but is usefull for production.
The other important setting is noauth if set true there will be no passwords. Its usefull to reset admin passwords. But be sure to turn this on by default.
The standard bind ip 0.0.0.0 is to make accept requests from the network not just local host.
I like to turn on the httpinterface (and rest) on port 27018 and 28018 as this shows usefull db information but be sure to block this to outside traffic.
Mongo really quick to setup and performance is smooth and quick. (some advanced scaling features are available as well).
It shines with rapid development as can easily add object to collection. (without having to redo data models and updating schemas)
Its python library pymongo works really well and works nicely with pythons dictionary datatypes. This makes data recall and storage quick and pleasant.
The structure of the database isn’t rigidly defined like sql and need to carefully manage what object data is loaded in what collection.
So try not to mix them. If adding extra data field would recommend going back to old objects and update to same form if possible.
I also recommend adding field “type” just for safety and sanity. I production may want to setup some integrity checks.
Second concern is the support for the user defined functions with the eval method losing support in the future