title: Node.js: whitelisting/redaction of database entries
body: <p>From node, I access a database with objects like</p>
  
  <pre><code>animals: [
  {
    name: monkey,
    diet: banana,
    tame: false,
  },
  {
    name: donkey,
    diet: carrot,
    tame: true,
  }
  // [...]
  ]
  </code></pre>
  
  <p>I'd like to give access to most of the data to the clients, but make sure that the <code>tame</code> property is <em>not</em> exposed.</p>
  
  <p>Using node and <a href="https://lodash.com/docs#pick" rel="nofollow">lodash's <code>pick()</code></a>, I could somehow whitelist the data, e.g.,</p>
  
  <pre><code>// retrieve data
  // [...]
  
  // whitelist
  return {
     name: _.pick(animal, 'name'),
     diet: _.pick(animal, 'diet'),
  };
  </code></pre>
  
  <p>but this is somewhat tedious, particularly if the selection of keys depends on other factors (e.g., the user who tries to access the data).</p>
  
  <p>What's are good whitelisting/<a href="https://docs.mongodb.org/v3.0/tutorial/implement-field-level-redaction/" rel="nofollow">redaction</a> patterns/modules for node?</p>