This repository was archived by the owner on Sep 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Add document:createOrReplace #61
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b0fb0e2
document:createOrReplace
y-abs ca70b08
remove queuable
y-abs 3e3be8e
Merge branch '3-dev' into KZL-1350-document-createOrReplace
y-abs 72d2b57
Update src/main/java/io/kuzzle/sdk/API/Controllers/DocumentController…
y-abs 0a9e0c8
requested changes
y-abs f68a118
Update doc/3/controllers/document/create-or-replace/index.md
y-abs 12b1175
@aschen requested change
y-abs 4f9d395
doc
y-abs 33606cb
Update doc/3/controllers/document/create-or-replace/snippets/create-o…
scottinet a41aa32
conflict [ci skip]
y-abs 1406dbe
Merge branch 'KZL-1350-document-createOrReplace' of github.com:kuzzle…
y-abs 06803d2
Merge branch '3-dev' into KZL-1350-document-createOrReplace
y-abs 32883d6
update Kuzzle.java
y-abs 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,55 @@ | ||
| --- | ||
| code: true | ||
| type: page | ||
| title: createOrReplace | ||
| description: Creates or replaces a document | ||
| --- | ||
|
|
||
| # createOrReplace | ||
|
|
||
| Creates a new document in the persistent data storage, or replaces its content if it already exists. | ||
|
|
||
| --- | ||
|
|
||
| ## Arguments | ||
|
|
||
| ```java | ||
| public CompletableFuture<ConcurrentHashMap<String, Object>> createOrReplace( | ||
| final String index, | ||
| final String collection, | ||
| final String id, | ||
| final ConcurrentHashMap<String, Object> document) | ||
| throws NotConnectedException, InternalException | ||
|
|
||
| public CompletableFuture<ConcurrentHashMap<String, Object>> createOrReplace( | ||
| final String index, | ||
| final String collection, | ||
| final String id, | ||
| final ConcurrentHashMap<String, Object> document, | ||
| final Boolean waitForRefresh) | ||
| throws NotConnectedException, InternalException | ||
| ``` | ||
|
|
||
| | Arguments | Type | Description | | ||
| | ------------------ | -------------------------------------------- | --------------------------------- | | ||
| | `index` | <pre>String</pre> | Index | | ||
| | `collection` | <pre>String</pre> | Collection | | ||
| | `id` | <pre>String</pre> | Document ID | | ||
| | `document` | <pre>ConcurrentHashMap<String, Object></pre> | Document content | | ||
| | `waitForRefresh` | <pre>Boolean</pre> | If set to `true`, Kuzzle will wait for the persistence layer to finish indexing| | ||
|
|
||
| --- | ||
|
|
||
| ## Return | ||
|
|
||
| A `ConcurrentHashMap` which has the following properties: | ||
|
|
||
| | Property | Type | Description | | ||
| |------------- |----------------------------- |--------------------------------- | | ||
| | `_source` | <pre>ConcurrentHashMap</pre> | Document content | | ||
| | `_id` | <pre>String</pre> | ID of the document | | ||
| | `_version` | <pre>Integer</pre> | Version of the document in the persistent data storage | | ||
|
|
||
| ## Usage | ||
|
|
||
| <<< ./snippets/create-or-replace.java | ||
25 changes: 25 additions & 0 deletions
25
doc/3/controllers/document/create-or-replace/snippets/create-or-replace.java
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,25 @@ | ||
|
|
||
| ConcurrentHashMap<String, Object> document = new ConcurrentHashMap<>(); | ||
| document.put("firstname", "John"); | ||
|
|
||
| ConcurrentHashMap<String, Object> result = kuzzle | ||
| .getDocumentController() | ||
| .createOrReplace("nyc-open-data", "yellow-taxi", "some-id", document) | ||
| .get(); | ||
|
|
||
| /* | ||
| { | ||
| _source= | ||
| { | ||
| firstname=John, | ||
| _kuzzle_info={ | ||
| createdAt=1582892323254, | ||
| author=-1, | ||
| updatedAt=1582892323254, | ||
| updater=-1 | ||
| } | ||
| }, | ||
| _id=some-id, | ||
| _version=1 | ||
| } | ||
| */ |
10 changes: 10 additions & 0 deletions
10
doc/3/controllers/document/create-or-replace/snippets/create-or-replace.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,10 @@ | ||
| name: document#createOrReplace | ||
| description: Creates or Replace a document | ||
| 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 | ||
| after: | ||
| template: print-result | ||
| expected: "firstname=John" |
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
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.
Uh oh!
There was an error while loading. Please reload this page.