Add document:update#59
Conversation
| curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi | ||
| after: | ||
| template: default | ||
| expected: "id: 'some-id'" No newline at end of file |
There was a problem hiding this comment.
I'm not sure that this test can pass. Can you add documentation snippet tests to travis to make sure of that?
8c1e0a2 to
b97884c
Compare
| ConcurrentHashMap<String, Object> response = | ||
| kuzzle.getDocumentController().update("nyc-open-data", "yellow-taxi", "some-id", content) | ||
| .get(); | ||
| System.out.println(response); No newline at end of file |
There was a problem hiding this comment.
Can you add the result of the println in comment?
It helps developer to better apprehend the structure of the response object they have. We try to do this for every method (Look the Javascript SDK and Doc)
| .put("body", document) | ||
| .put("_id", id) | ||
| .put("waitForRefresh", _options != null ? _options.getBoolean("waitForRefresh") : null) | ||
| .put("retryOnConflict", _options != null ? _options.getNumber("retryOnConflict") : 0) |
There was a problem hiding this comment.
You should let Kuzzle handle default values
| .put("retryOnConflict", _options != null ? _options.getNumber("retryOnConflict") : 0) | |
| .put("retryOnConflict", _options != null ? _options.getNumber("retryOnConflict") : null) |
There was a problem hiding this comment.
When its null Kuzzle throw an error
There was a problem hiding this comment.
Confirmed, but this sounds like a bug in Kuzzle. So I fixed it: kuzzleio/kuzzle#1579
Aschen's point still stands.
There was a problem hiding this comment.
Okay thanks!
So unfortunately, until it's released, the snippet test will fail
There was a problem hiding this comment.
Ok I'm releasing kuzzle 2.1.1 then
There was a problem hiding this comment.
@Yoann-Abbes > kuzzle 2.1.1 released
Co-Authored-By: Adrien Maret <amaret93@gmail.com>
…va into KZL-1350-document-update
| final String collection, | ||
| final String id, | ||
| final ConcurrentHashMap<String, Object> document, | ||
| final ConcurrentHashMap<String, Object> options) |
There was a problem hiding this comment.
We should have a DocumentOptions class containing waitForRefresh, retryOnConflict and source
| final String collection, | ||
| final String id, | ||
| final ConcurrentHashMap<String, Object> document, | ||
| final DocumentOptions options) |
There was a problem hiding this comment.
I disagree with that name: that option class can only be passed to methods having a use for all its exposed options, namely waitForRefresh, retryOnConflict and source. These last 2 in particular are only relevant for update (and possibly mUpdate) methods.
You have to design 1 option class per "use" (in term of functionalities), meaning that all options must have meaning for a particular method. If you use a "DocumentOption" class for methods having no use for the retryOnConflict option for instance, then this can be hard for users to understand.
Rename this to UpdateOptions, DocumentUpdateOptions, or whatever is more fitting for this method.
There was a problem hiding this comment.
I just saw that DocumentOptions already existed prior to this PR, and that it contains an id option for methods such as document.create.
This makes my point even more relevant: the update method has no use for that id option, and this can even be very confusing for users, as the update method already takes an "id" argument.
…va into KZL-1350-document-update
Co-Authored-By: Sébastien Cottinet <scottinet@protonmail.com>
What does this PR do ?
This PR implements the
document:updatemethod with its unit tests.How should this be manually tested?
Clone this branch and run unit tests
./gradlew testWhen it succeed, compile it
./gradlew jarInitiate another java project by adding the compiled SDK as a dependency.
Then, run Kuzzle, create an index
nyc-open-dataand ayellow-taxicollection in the admin console. Create a document with idsome-idand content:Finally, run this code
You should see the document updated in your collection.
You can test without options as well
Other changes
Update subscribe documentation -> Remove non existing snippets
Remove class
DocumentOptionsand add aCreateOptionsclass