Skip to content
This repository was archived by the owner on Sep 28, 2022. It is now read-only.

Add document:mUpdate#70

Merged
scottinet merged 21 commits into
3-devfrom
KZL-1350-document-mUpdate
Mar 23, 2020
Merged

Add document:mUpdate#70
scottinet merged 21 commits into
3-devfrom
KZL-1350-document-mUpdate

Conversation

@y-abs
Copy link
Copy Markdown
Contributor

@y-abs y-abs commented Mar 5, 2020

What does this PR do ?

This PR implements the mUpdate method with its unit tests.

How should this be manually tested?

Clone this branch and run unit tests
./gradlew test

When it succeed, compile it

./gradlew jar

Initiate another java project by adding the compiled SDK as a dependency.

Then, run Kuzzle, create an index nyc-open-data and a yellow-taxi collection in the admin console. Create 2 documents some-id1 and some-id2.
Finally, run this code

import io.kuzzle.sdk.*;
import io.kuzzle.sdk.Options.KuzzleOptions;
import io.kuzzle.sdk.Options.Protocol.WebSocketOptions;
import io.kuzzle.sdk.Protocol.WebSocket;

import java.util.concurrent.ConcurrentHashMap;

public class mUpdateDocument {
    private static Kuzzle kuzzle;

    public static void main(String[] args) {
        WebSocketOptions opts = new WebSocketOptions();
        opts.setAutoReconnect(true).setConnectionTimeout(42000);

        try {
            WebSocket ws = new WebSocket("localhost", opts);

            kuzzle = new Kuzzle(ws, (KuzzleOptions) null);

            kuzzle.connect();

            ConcurrentHashMap<String, Object> document1 = new ConcurrentHashMap<>();
            ConcurrentHashMap<String, Object> body1 = new ConcurrentHashMap<>();

            ConcurrentHashMap<String, Object> document2 = new ConcurrentHashMap<>();
            ConcurrentHashMap<String, Object> body2 = new ConcurrentHashMap<>();

            document1.put("_id", "some-id1");
            body1.put("key", "value");
            document1.put("body", body1);

            document2.put("_id", "some-id2");
            body2.put("key", "value");
            document2.put("body", body2);

            ArrayList<ConcurrentHashMap<String, Object>> content = new ArrayList<>();
            content.add(document1);
            content.add(document2);

            ConcurrentHashMap<String, Object> response =
            kuzzle.getDocumentController().mUpdate("nyc-open-data", "yellow-taxi", content)
            .get();

            System.out.println(response);
        }  catch (Exception e) {
            e.printStackTrace();
        }

        kuzzle.disconnect();
    }
};

You should see the documents updated.

@y-abs y-abs self-assigned this Mar 5, 2020
Comment thread doc/3/controllers/document/m-update/index.md Outdated
@y-abs y-abs requested a review from scottinet March 13, 2020 14:11

| Arguments | Type | Description |
| ------------------ | -------------------------------------------- | --------------------------------- |
| `_id` | <pre>String</pre> | Optional document ID. Will be auto-generated if not defined. |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be copy-pasted from the document:create documentation: document identifiers are not optional for update methods.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In deed

Comment thread doc/3/controllers/document/m-update/index.md Outdated
@y-abs y-abs requested a review from scottinet March 17, 2020 09:14
@scottinet scottinet merged commit e220c08 into 3-dev Mar 23, 2020
@scottinet scottinet deleted the KZL-1350-document-mUpdate branch March 23, 2020 17:05
@jenow jenow mentioned this pull request May 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants