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

docs: remove fields filter warning #5856

Merged
merged 1 commit into from
Jun 30, 2020
Merged

docs: remove fields filter warning #5856

merged 1 commit into from
Jun 30, 2020

Conversation

jannyHou
Copy link
Contributor

@jannyHou jannyHou commented Jun 30, 2020

Update docs after fixing #4992

Checklist

👉 Read and sign the CLA (Contributor License Agreement) 👈

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

👉 Check out how to submit a PR 👈

@agnes512 agnes512 self-requested a review June 30, 2020 15:59
Copy link
Contributor

@agnes512 agnes512 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example in L52-53:

/customers?filter[fields][id]=false&filter[fields][name]=true&filter[fields][address]=true

Or omit the name field:

/customers?filter[fields][name]=true&filter[fields][address]=true

@@ -27,9 +27,6 @@ query will include **only** those you specifically include with filters.

### REST API

{% include warning.html content="
As a known bug, the option `<false>` does not work for url for now. Please include the properties you need or use the [stringified JSON format](Querying-data.html#using-stringified-json-in-rest-queries) to meet your requirement. The bug is tracked in the GH issue [#4992](https://github.com/strongloop/loopback-next/issues/4992)" %}

<pre>
filter[fields][<i>propertyName</i>]=true&filter[fields][<i>propertyName</i>]=true...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

->
filter[fields][propertyName]=true|false&filter[fields][propertyName]=true|false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated 👍

@jannyHou jannyHou force-pushed the doc/fields-filter branch from dc99d97 to cff264d Compare June 30, 2020 16:30
@jannyHou
Copy link
Contributor Author

@agnes512 Thank you, I adjusted the content a bit, now it's:

Return customer information only with name and address, and hide their id:

await customerRepository.find({fields: {id: false, name: true, address: true}});

Or use stringified JSON format:
/orders?filter={"fields":{"name":true,"address":true,"id":false}}

Include all required properties:
/customers?filter[fields][name]=true&filter[fields][address]=true

Or omit the hidden property:
/customers?filter[fields][id]=false

@@ -50,14 +47,18 @@ Return customer information only with `name` and `address`, and hide their `id`:
await customerRepository.find({fields: {id: false, name: true, address: true}});
```

Or use stringified JSON format:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick:
Other filters have the stringified JSON format example after the REST examples.


`/orders?filter={"fields":{"name":true,"address":true,"id":false}}`
`/customers?filter[fields][id]=false`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw this might not be correct if the model has properties other than id, name, and address.

@jannyHou jannyHou force-pushed the doc/fields-filter branch from cff264d to ea6e0f8 Compare June 30, 2020 17:15
@jannyHou
Copy link
Contributor Author

@agnes512 I just realized there are 2 separate examples for include and exclude, re-wrote the content, ptal thanks!

Copy link
Contributor

@agnes512 agnes512 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jannyHou jannyHou merged commit ee09cf7 into master Jun 30, 2020
@jannyHou jannyHou deleted the doc/fields-filter branch June 30, 2020 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants