0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/core/server/models
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
..
base Reduce toJSON implementation: use the power of bookshelf (#9423) 2018-02-14 17:32:11 +01:00
plugins Reduce toJSON implementation: use the power of bookshelf (#9423) 2018-02-14 17:32:11 +01:00
accesstoken.js Import lib/common only 2017-12-12 10:28:13 +01:00
app-field.js
app-setting.js
app.js Switch to Eslint (#9197) 2017-11-01 13:44:54 +00:00
client-trusted-domain.js Add table columns for OAuth 2015-09-02 13:39:22 +01:00
client.js 🎨 😎 config env usages (#7929) 2017-02-03 18:25:39 +00:00
index.js Webhooks support for subscriber events (#9230) 2017-11-21 15:43:14 +00:00
invite.js Reduce toJSON implementation: use the power of bookshelf (#9423) 2018-02-14 17:32:11 +01:00
permission.js
post.js Contributor Role (#9315) 2018-02-07 10:46:22 +01:00
refreshtoken.js
role.js Contributor Role (#9315) 2018-02-07 10:46:22 +01:00
settings.js Import lib/common only 2017-12-12 10:28:13 +01:00
subscriber.js Import lib/common only 2017-12-12 10:28:13 +01:00
tag.js Import lib/common only 2017-12-12 10:28:13 +01:00
user.js Reduce toJSON implementation: use the power of bookshelf (#9423) 2018-02-14 17:32:11 +01:00
webhook.js Import lib/common only 2017-12-12 10:28:13 +01:00