-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation for select and omit
- Loading branch information
Joel Bradshaw
committed
Mar 3, 2022
1 parent
06ce9cf
commit 5db1430
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"> |