Created
May 1, 2014 13:23
-
-
Save secretfader/747c145ea9df4835e7cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: '[email protected]' | |
} | |
}; | |
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