-
Notifications
You must be signed in to change notification settings - Fork 16
Add support for the document:deleteFields API action #636
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9b9f2f6
add deleteFields action
Shiranuit 0d3bf56
add test for deleteFields
Shiranuit 109458d
add doc and snippet
Shiranuit 091e53c
add timeout option
Shiranuit 05658d1
add timeout option
Shiranuit 86220fe
fix lint not passing because of the deconstructor operator causing an…
Shiranuit 0600843
replace Array<string> with string[]
Shiranuit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,46 @@ | ||
--- | ||
code: true | ||
type: page | ||
title: deleteFields | ||
description: Deletes fields of an existing document. | ||
--- | ||
|
||
# delete | ||
|
||
Deletes fields of an existing document. | ||
|
||
The optional parameter `refresh` can be used with the value `wait_for` in order to wait for the document to be indexed (and to no longer be available in search). | ||
|
||
<br/> | ||
|
||
```js | ||
deleteFields (index, collection, id, fields, [options]); | ||
``` | ||
|
||
| Argument | Type | Description | | ||
| ------------ | ------------------- | ------------------------------------------------------------------ | | ||
| `index` | <pre>string</pre> | Index name | | ||
| `collection` | <pre>string</pre> | Collection name | | ||
| `id` | <pre>string</pre> | Document ID | | ||
| `fields` | <pre>string[]</pre> | [Path](https://lodash.com/docs/4.17.15#toPath) of fields to delete | | ||
| `options` | <pre>object</pre> | Query options | | ||
|
||
### Options | ||
|
||
Additional query options | ||
|
||
| Options | Type<br/>(default) | Description | | ||
| ---------- | -------------------------------- | --------------------------------------------------------------------------------------------------------------------- | | ||
| `queuable` | <pre>boolean</pre><br/>(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | | ||
| `refresh` | <pre>string</pre><br/>(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | | ||
| `silent` | <pre>boolean</pre><br/>(`false`) | If `true`, then Kuzzle will not generate notifications <SinceBadge version="7.5.3"/> | | ||
| `source` | <pre>boolean</pre><br/>(`false`) | If `true`, then the response will contain the updated document | | ||
| `timeout` | <pre>number</pre> | Time (in ms) during which a request will still be waited to be resolved. Set it `-1` if you want to wait indefinitely | | ||
|
||
## Resolves | ||
|
||
Resolves to updated document. | ||
|
||
## Usage | ||
|
||
<<< ./snippets/deleteFields.js |
7 changes: 7 additions & 0 deletions
7
doc/7/controllers/document/delete-fields/snippets/deleteFields.js
This file contains hidden or 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,7 @@ | ||
try { | ||
const response = await kuzzle.document.deleteFields('nyc-open-data', 'yellow-taxi', 'some-id', ['bar'], {source: true}); | ||
|
||
console.log(response._source); | ||
} catch (error) { | ||
console.error(error.message); | ||
} |
11 changes: 11 additions & 0 deletions
11
doc/7/controllers/document/delete-fields/snippets/deleteFields.test.yml
This file contains hidden or 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,11 @@ | ||
name: document#delete | ||
description: Deletes a document from kuzzle | ||
hooks: | ||
before: | | ||
curl -XDELETE kuzzle:7512/nyc-open-data | ||
curl -XPOST kuzzle:7512/nyc-open-data/_create | ||
curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi | ||
curl --fail -H "Content-type: application/json" -XPUT -d '{"foo": "bar", "bar": "baz"}' kuzzle:7512/nyc-open-data/yellow-taxi/some-id | ||
after: | ||
template: default | ||
expected: {"foo": "bar"} |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit