Ghost/core/server/models/base
Katharina Irrgang 9ede5905f6
Reduce toJSON implementation: use the power of bookshelf (#9423)
refs #6103

- simplify `toJSON`
- `baseKey` was not used - have not find a single use case
- all the functionality of our `toJSON` is offered in bookshelf
- `omitPivot` does remove pivot elements from the JSON obj (bookshelf feature)
- `shallow` allows you to not return relations
- make use of `serialize`, see http://bookshelfjs.org/docs/src_base_model.js.html#line260
- fetching nested relations e.g. `users.roles` still works (unrelated to this refactoring)

> pick('shallow', 'baseKey', 'include', 'context')

We will re-add options validation in https://github.com/TryGhost/Ghost/pull/9427, but then with the official way: use `filterOptions`.

---

We return all fetched relations (pre-defined with `withRelated`) by default.
You can disable it with `shallow:true`.
2018-02-14 17:32:11 +01:00
..
index.js Reduce toJSON implementation: use the power of bookshelf (#9423) 2018-02-14 17:32:11 +01:00
listeners.js Avoid knex warning when destroying a user 2018-01-27 12:31:51 +01:00
token.js Import lib/common only 2017-12-12 10:28:13 +01:00
utils.js Import lib/common only 2017-12-12 10:28:13 +01:00