Skip to content

Commit

Permalink
Merge pull request #729 from kuzzleio/documentation/exists
Browse files Browse the repository at this point in the history
chore(documentation): Add exists documentation
  • Loading branch information
rolljee authored Aug 30, 2023
2 parents d9660d3 + 66c1ae2 commit 2257670
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: document#delete
description: Deletes a document from kuzzle
description: Deletes a field from a document in kuzzle
hooks:
before: |
curl -XDELETE kuzzle:7512/nyc-open-data
Expand Down
42 changes: 42 additions & 0 deletions doc/7/controllers/document/exists/index.md
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
7 changes: 7 additions & 0 deletions doc/7/controllers/document/exists/snippets/exists.js
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 doc/7/controllers/document/exists/snippets/exists.test.yml
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

0 comments on commit 2257670

Please sign in to comment.