-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #729 from kuzzleio/documentation/exists
chore(documentation): Add exists documentation
- Loading branch information
Showing
4 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
doc/7/controllers/document/delete-fields/snippets/deleteFields.test.yml
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,42 @@ | ||
--- | ||
code: true | ||
type: page | ||
title: exists | ||
description: Check if a document exists inside kuzzle | ||
--- | ||
|
||
# exists | ||
|
||
Check if a document exists. | ||
|
||
<br/> | ||
|
||
```js | ||
exists (index, collection, id, [options]); | ||
``` | ||
|
||
| Argument | Type | Description | | ||
| ------------ | ----------------- | --------------- | | ||
| `index` | <pre>string</pre> | Index name | | ||
| `collection` | <pre>string</pre> | Collection name | | ||
| `id` | <pre>string</pre> | Document ID | | ||
| `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"/> | | ||
| [`timeout`](/sdk/7/core-classes/kuzzle/query#timeout) | <pre>number</pre><br/>(`-1`) | 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 a boolean. | ||
|
||
## Usage | ||
|
||
<<< ./snippets/exists.js |
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,7 @@ | ||
try { | ||
const response = await kuzzle.document.exists('nyc-open-data', 'yellow-taxi', 'some-id'); | ||
|
||
console.log(response); | ||
} catch (error) { | ||
console.error(error.message); | ||
} |
11 changes: 11 additions & 0 deletions
11
doc/7/controllers/document/exists/snippets/exists.test.yml
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,11 @@ | ||
name: document#exists | ||
description: Check if a document exists in 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 '{}' kuzzle:7512/nyc-open-data/yellow-taxi/some-id | ||
after: | ||
template: default | ||
expected: true |