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

[patch] Add documentation for select and omit #7208

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
20 changes: 20 additions & 0 deletions docs/concepts/ORM/Querylanguage.md
Expand Up @@ -235,10 +235,30 @@ _For performance reasons, case-sensitivity of `endsWith` depends on the database
Query options allow you refine the results that are returned from a query. They are used
in conjunction with a `where` key. The current options available are:

* `select`
* `omit`
* `limit`
* `skip`
* `sort`

#### Select

Chooses which attributes to return from a query. Note that `id` is always
returned, even if not included in the `select` list.

```usage
Model.find({ select: ['name'] })
```

#### Omit

Chooses which attributes to omit from a query. All attributes except for the
given attributes will be returned.

```usage
Model.find({ omit: ['middleName'] })
```

#### Limit

Limits the number of results returned from a query.
Expand Down
30 changes: 30 additions & 0 deletions docs/reference/waterline/queries/omit.md
@@ -0,0 +1,30 @@
# `.omit()`

Indicate which attributes to omit from the query. All attributes except for the
given attributes will be returned.

```usage
.omit(attributesToOmit)
```


### Usage

| | Argument | Type | Details |
|---|:------------------|-----------|------------|
| 1 | attributesToOmit | ((array)) | The names of fields to omit. |


### Example

To retrieve all attributes but `password` from the user named Rosa:

```javascript
var rosa = await User.findOne({ name: 'Rosa' })
.omit(['password'])

return res.json(rosa);
```

<docmeta name="displayName" value=".omit()">
<docmeta name="pageType" value="method">
30 changes: 30 additions & 0 deletions docs/reference/waterline/queries/select.md
@@ -0,0 +1,30 @@
# `.select()`

Indicate which attributes to select from the query. All attributes except for the
given attributes will be returned.

```usage
.select(attributesToInclude)
```


### Usage

| | Argument | Type | Details |
|---|:---------------------|-----------|------------|
| 1 | attributesToInclude | ((array)) | The names of fields to select. |


### Example

To retrieve only `name` from the user with id 1234

```javascript
var userInfo = await User.findOne({ id: 1234 })
.select(['name'])

return res.json(userInfo);
```

<docmeta name="displayName" value=".select()">
<docmeta name="pageType" value="method">