Skip to content

Instantly share code, notes, and snippets.

@secretfader
Created May 1, 2014 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save secretfader/747c145ea9df4835e7cc to your computer and use it in GitHub Desktop.
Save secretfader/747c145ea9df4835e7cc to your computer and use it in GitHub Desktop.
var distill = require('distill');
var data = {
id: 1,
title: 'Hello, World',
dirty_field: 'This field should not be exposed.',
authors: {
id: 2,
name: 'Joshua',
email: 'joshua@example.org'
}
};
var output =
distill(data)
.field('id')
.field('title')
.embed('authors', 'id')
.bottle();
// Output
{
id: 1,
title: 'Hello, World',
authors: [
{ id: 2 }
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment