diff --git a/docs/concepts/ORM/Querylanguage.md b/docs/concepts/ORM/Querylanguage.md index 78e4f82bd..7e2e17d38 100644 --- a/docs/concepts/ORM/Querylanguage.md +++ b/docs/concepts/ORM/Querylanguage.md @@ -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. diff --git a/docs/reference/waterline/queries/omit.md b/docs/reference/waterline/queries/omit.md new file mode 100644 index 000000000..2fef5db13 --- /dev/null +++ b/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); +``` + + + diff --git a/docs/reference/waterline/queries/select.md b/docs/reference/waterline/queries/select.md new file mode 100644 index 000000000..81a5771d4 --- /dev/null +++ b/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); +``` + + +