Skip to content

Commit 201f36b

Browse files
committed
chore(documentation): Add exists documentation
1 parent d9660d3 commit 201f36b

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
code: true
3+
type: page
4+
title: exists
5+
description: Check if a document exists inside kuzzle
6+
---
7+
8+
# exists
9+
10+
Check if a document exists.
11+
12+
<br/>
13+
14+
```js
15+
exists (index, collection, id, [options]);
16+
```
17+
18+
| Argument | Type | Description |
19+
| ------------ | ----------------- | --------------- |
20+
| `index` | <pre>string</pre> | Index name |
21+
| `collection` | <pre>string</pre> | Collection name |
22+
| `id` | <pre>string</pre> | Document ID |
23+
| `options` | <pre>object</pre> | Query options |
24+
25+
### Options
26+
27+
Additional query options
28+
29+
| Options | Type<br/>(default) | Description |
30+
| ---------- | -------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
31+
| `queuable` | <pre>boolean</pre><br/>(`true`) | If true, queues the request during downtime, until connected to Kuzzle again |
32+
| `refresh` | <pre>string</pre><br/>(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) |
33+
| `silent` | <pre>boolean</pre><br/>(`false`) | If `true`, then Kuzzle will not generate notifications <SinceBadge version="7.5.3"/> |
34+
| [`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 |
35+
36+
## Resolves
37+
38+
Resolves a boolean.
39+
40+
## Usage
41+
42+
<<< ./snippets/exists.js
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
try {
2+
const { result } = await kuzzle.document.exists('nyc-open-data', 'yellow-taxi', 'some-id');
3+
4+
if (result) {
5+
console.log('Success');
6+
}
7+
} catch (error) {
8+
console.error(error.message);
9+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: document#exists
2+
description: Check if a document exists in kuzzle
3+
hooks:
4+
before: |
5+
curl -XDELETE kuzzle:7512/nyc-open-data
6+
curl -XPOST kuzzle:7512/nyc-open-data/_create
7+
curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi
8+
curl --fail -H "Content-type: application/json" -XPUT -d '{}' kuzzle:7512/nyc-open-data/yellow-taxi/some-id
9+
after:
10+
template: default
11+
expected: Success

0 commit comments

Comments
 (0)