5 August 2012

Subscribe to Engineering Growth

Stay up to date on new essays and updates on Growth Engineering.

A quick public service announcement about MongoDB, for those of us new to NoSQL land:

** By default, mongo will not let you know if a query that you ran failed miserably.**

On the bright side, you on longer need to wait for mongo to unblock for updates or inserts, which makes production code run quicker.

Unfortunately, this also means you’re going to spend more time tracking down bugs that would have been caught by IntegrityErrors (or the equivalent) in good old SQLite.

** But I LIKE knowing about integrity errors**. Me too, especially when testing locally.

Here’s the fix: set safe=True in your Mongo connection object. In django non-rel, this means setting

    DATABASES = {
      'default': {
        ...
        'OPTIONS': {
          'safe': True
        },
      },
    }

in settings.py.

Good luck!

Tags: #technical #advice