Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typo in customToJSON documentation #7338

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/concepts/ORM/model-settings.md
Expand Up @@ -75,7 +75,7 @@ customToJSON: function() { /*...*/ }
| ------------ |:------------------------|:--------------|
| ((function)) | _See below._ | _n/a_ |

Adding the `customToJSON` setting to a model changes the way that the model’s records are _stringified_. In other words, it allows you to inject custom logic that runs any time one of these records are passed into `JSON.stringify()`. This is most commonly used to implement a failsafe, making sure sensitive data like user passwords aren't accidentally included in a response (since [`res.send()`](https://sailsjs.com/documentation/reference/response-res/res-send) and actions2 may stringify data before sending).
Adding the `customToJSON` setting to a model changes the way that the model’s records are _stringified_. In other words, it allows you to inject custom logic that runs any time one of these records are passed into `JSON.stringify()`. This is most commonly used to implement a failsafe, making sure sensitive data like user passwords aren't accidentally included in a response (since [`res.send()`](https://sailsjs.com/documentation/reference/response-res/res-send) and actions may stringify data before sending).

The `customToJSON` function takes no arguments, but provides access to the record as the `this` variable. This allows you to omit sensitive data and return the sanitized result, which is what `JSON.stringify()` will actually use when generating a JSON string. For example:

Expand Down