Ghost/core/server/models/plugins
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
..
collision.js Import lib/common only 2017-12-12 10:28:13 +01:00
filter.js Deleted bookshelf access plugin 2018-01-25 17:54:28 +01:00
include-count.js Reduce toJSON implementation: use the power of bookshelf (#9423) 2018-02-14 17:32:11 +01:00
index.js Deleted bookshelf access plugin 2018-01-25 17:54:28 +01:00
pagination.js Import lib/common only 2017-12-12 10:28:13 +01:00