Mel Reams

Nerrrrd

Mongo tip of the day

If you use Mongo’s mapReduce, pay close attention to which action you output to another collection with, especially if you’re using multiple mapReduces to perform a join. The merge action doesn’t do what you might expect – it merges at the collection level by overwriting the results of the first mapReduce with any results from the second that have the same key. If you want to merge at a document level, which is kind of important if you’re trying to join two collections, you need to use the reduce action, which runs all the documents for each key through your reduce function, which can then decide how to merge those two objects into one (null checks, lots of null checks).

As you may have guessed, I learned this the hard way when the fields set by my first mapReduce got set back to null by the second one. Just because you think you know what “merge” does that doesn’t mean you shouldn’t still read the docs.

Ember tip of the day

If you happen to find some example code that elegantly solves your exact problem, check which version of Ember it uses. Sometimes that perfect example is a few versions ahead and will do absolutely nothing for you. If you’re smarter than I am and check the version number right away, you can save yourself a good half hour of cleaning, rebuilding, and cursing.

On the upside, if you need to iterate over a map with {{#each foo in bar}}, you can hammer together a workaround using Ember.keys(map) – but again, only if you have the right version of ember. Ember.keys() was deprecated in 1.13, use Object.keys() instead if your version of Ember is later than 1.13.

 

WordPress Appliance - Powered by TurnKey Linux