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

Update ExampleHelper.md to use const #7256

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions docs/concepts/Helpers/ExampleHelper.md
Expand Up @@ -52,7 +52,7 @@ module.exports = {
fn: async function (inputs, exits) {

// Run the query
var users = await User.find({
const users = await User.find({
active: true,
lastLogin: { '>': inputs.activeSince }
})
Expand All @@ -77,13 +77,13 @@ module.exports = {
To call this helper from app code using the default options (in an action, for example), we would use:

```javascript
var users = await sails.helpers.getRecentUsers();
const users = await sails.helpers.getRecentUsers();
```

To alter the criteria for the returned users, we could pass in some values:

```javascript
var users = await sails.helpers.getRecentUsers(50);
const users = await sails.helpers.getRecentUsers(50);
```

Or, to get the 10 most recent users who have logged in since St. Patrick's Day, 2017:
Expand All @@ -109,7 +109,7 @@ await sails.helpers.getRecentUsers.with({
Finally, to handle the `noUsersFound` exit explicitly rather than simply treating it like any other error, we can use [`.intercept()`](https://sailsjs.com/documentation/reference/waterline-orm/queries/intercept) or [`.tolerate()`](https://sailsjs.com/documentation/reference/waterline-orm/queries/tolerate):

```javascript
var users = await sails.helpers.getRecentUsers(10)
const users = await sails.helpers.getRecentUsers(10)
.tolerate('noUsersFound', ()=>{
// ... handle the case where no users were found. For example:
sails.log.verbose(
Expand All @@ -121,7 +121,7 @@ var users = await sails.helpers.getRecentUsers(10)
```

```javascript
var users = await sails.helpers.getRecentUsers(10)
const users = await sails.helpers.getRecentUsers(10)
.intercept('noUsersFound', ()=>{
return new Error('Inconceivably, no active users were found for that timeframe.');
});
Expand Down