Last active
August 29, 2015 14:19
-
-
Save VictorQueiroz/363b58702882d98fa25a to your computer and use it in GitHub Desktop.
Bookshelf.js - Removing pivots from returned data
This file contains hidden or 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
| 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