Skip to content

Instantly share code, notes, and snippets.

@VictorQueiroz
Last active August 29, 2015 14:19
Show Gist options
  • Select an option

  • Save VictorQueiroz/363b58702882d98fa25a to your computer and use it in GitHub Desktop.

Select an option

Save VictorQueiroz/363b58702882d98fa25a to your computer and use it in GitHub Desktop.
Bookshelf.js - Removing pivots from returned data
Account.forge({
id: 1
}).fetch({
withRelated: ['accounts']
}).then(function (account) {
return account.related('accounts');
}).then(function (accounts) {
var account = accounts.at(0).toJSON({ omitPivot: true });
res.json(account);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment