From 8adab4df16491b89c02d682d470b758c07eec9ff Mon Sep 17 00:00:00 2001 From: Yoann Abbes Date: Thu, 4 Jun 2020 17:50:19 +0200 Subject: [PATCH 01/10] Add document:updateByQuery --- .ci/doc/templates/print-result-array.tpl.js | 35 ++++++++++ .../document/update-by-query/index.md | 64 +++++++++++++++++ .../snippets/update-by-query.js | 30 ++++++++ .../snippets/update-by-query.test.yml | 19 +++++ src/controllers/Document.js | 13 ++++ src/protocols/routes.json | 4 ++ test/controllers/document.test.js | 69 +++++++++++++++++++ 7 files changed, 234 insertions(+) create mode 100644 .ci/doc/templates/print-result-array.tpl.js create mode 100644 doc/7/controllers/document/update-by-query/index.md create mode 100644 doc/7/controllers/document/update-by-query/snippets/update-by-query.js create mode 100644 doc/7/controllers/document/update-by-query/snippets/update-by-query.test.yml diff --git a/.ci/doc/templates/print-result-array.tpl.js b/.ci/doc/templates/print-result-array.tpl.js new file mode 100644 index 000000000..9619adede --- /dev/null +++ b/.ci/doc/templates/print-result-array.tpl.js @@ -0,0 +1,35 @@ +// Loads the Kuzzle SDK module and the websocket protocol +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client +const + kuzzle = new Kuzzle( + new WebSocket('kuzzle', { autoReconnect: false }) + ); + +// Adds a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error.message}`); +}); + +(async () => { + try { + await kuzzle.connect(); + } catch (error) { + console.log(`Can not connect to Kuzzle: ${error.message}`); + } + try { + [snippet-code] + console.log(result.successes); + for (const elem of result.successes) { + console.log(elem); + } + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +})(); diff --git a/doc/7/controllers/document/update-by-query/index.md b/doc/7/controllers/document/update-by-query/index.md new file mode 100644 index 000000000..e124bb807 --- /dev/null +++ b/doc/7/controllers/document/update-by-query/index.md @@ -0,0 +1,64 @@ +--- +code: true +type: page +title: updateByQuery +description: Updates documents matching query +--- + +# updateByQuery + +Updates documents matching the provided search query. + +Kuzzle uses the [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/query-dsl.html) syntax. + +An empty or null query will match all documents in the collection. + +
+ +```js +updateByQuery(index, collection, body, [options]) +``` + +| Argument | Type | Description | +| ------------------ | -------------------------------------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `searchQuery` |
object
| Query to match | +| `changes` |
object
| Partial changes to apply to the documents | +| `options` |
object
| Optional parameters | + +--- + +### options + +Additional query options. + +| Options | Type
(default) | Description | +| ----------------- | ------------------------------- | ---------------------------------------------------------------------------------- | +| `refresh` |
string

(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | +| `source` |
boolean

(`false`)| If true, returns the updated document inside the response + +## Resolves + +Returns an object containing 2 arrays: `successes` and `errors` + +Each updated document is an object of the `successes` array with the following properties: + +| Property | Type | Description | +|------------- |--------------------------------------------- |--------------------------------- | +| `_source` |
ConcurrentHashMap
| Updated document (if `source` option set to true) | +| `_id` |
String
| ID of the udated document | +| `_version` |
Integer
| Version of the document in the persistent data storage | +| `status` |
Integer
| HTTP status code | + +Each errored document is an object of the `errors` array with the following properties: + +| Property | Type | Description | +|------------- |--------------------------------------------- |--------------------------------- | +| `document` |
ConcurrentHashMap
| Document that causes the error | +| `status` |
Integer
| HTTP error status | +| `reason` |
String
| Human readable reason | + +## Usage + +<<< ./snippets/update-by-query.js \ No newline at end of file diff --git a/doc/7/controllers/document/update-by-query/snippets/update-by-query.js b/doc/7/controllers/document/update-by-query/snippets/update-by-query.js new file mode 100644 index 000000000..9dd7caaff --- /dev/null +++ b/doc/7/controllers/document/update-by-query/snippets/update-by-query.js @@ -0,0 +1,30 @@ +const result = await kuzzle.document.updateByQuery( + 'nyc-open-data', + 'yellow-taxi', + { + query: { + match: { + capacity: 4 + } + }, + changes: { + capacity: 42 + } + }); +/* +{ + successes: [ + { + _id: , + _source: // if source set to true + status: 200 + }, + { + _id: , + _source: // if source set to true + status: 200 + } + ], + errors: [] + } + */ \ No newline at end of file diff --git a/doc/7/controllers/document/update-by-query/snippets/update-by-query.test.yml b/doc/7/controllers/document/update-by-query/snippets/update-by-query.test.yml new file mode 100644 index 000000000..49ad46eb0 --- /dev/null +++ b/doc/7/controllers/document/update-by-query/snippets/update-by-query.test.yml @@ -0,0 +1,19 @@ +name: document#updateByQuery +description: Update documents matching query +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 + for i in 1 2 ; do + curl -H "Content-type: application/json" -d '{"capacity": 4}' kuzzle:7512/nyc-open-data/yellow-taxi/document_$i/_create + done + for i in 1 2 3 4 5; do + curl -H "Content-type: application/json" -d '{"capacity": 7}' kuzzle:7512/nyc-open-data/yellow-taxi/_create + done + curl -XPOST kuzzle:7512/nyc-open-data/_refresh + after: +template: print-result-array +expected: + - "id: document_1, _version: 2, status: 200" + - "id: document_2, _version: 2, status: 200" \ No newline at end of file diff --git a/src/controllers/Document.js b/src/controllers/Document.js index bf62cacd0..4b8d84666 100644 --- a/src/controllers/Document.js +++ b/src/controllers/Document.js @@ -220,6 +220,19 @@ class DocumentController extends BaseController { .then(response => response.result); } + updateByQuery(index, collection, body, options = {}) { + const request = { + index, + collection, + body, + action: 'updateByQuery', + source: options.source + }; + + return this.query(request, options) + .then(response => response.result); + } + validate (index, collection, body, options = {}) { return this.query({ index, diff --git a/src/protocols/routes.json b/src/protocols/routes.json index 1a6836f0d..8318e5cc0 100644 --- a/src/protocols/routes.json +++ b/src/protocols/routes.json @@ -116,6 +116,10 @@ "url": "/:index/:collection/:_id/_update", "verb": "PUT" }, + "updateByQuery": { + "url": "/:index/:collection/_query", + "verb": "PUT" + }, "mUpdate": { "url": "/:index/:collection/_mUpdate", "verb": "PUT" diff --git a/test/controllers/document.test.js b/test/controllers/document.test.js index 5ab034ef9..abdb1d6ab 100644 --- a/test/controllers/document.test.js +++ b/test/controllers/document.test.js @@ -563,6 +563,75 @@ describe('Document Controller', () => { }); }); + describe('updateByQuery', () => { + it('should call document/update query and return a Promise which resolves the updated document', () => { + const result = { + _id: 'document-id', + _version: 1, + _source: { foo: 'bar' }, + created: false + }; + kuzzle.query.resolves({ result }); + const body = { + query: { + match: { foo: 'bar' } + }, + changes: { + bar: 'foo' + } + }; + return kuzzle.document.updateByQuery('index', 'collection', body, options) + .then(res => { + should(kuzzle.query) + .be.calledOnce() + .be.calledWith({ + controller: 'document', + action: 'updateByQuery', + index: 'index', + collection: 'collection', + body, + source: undefined + }, options); + + should(res).be.equal(result); + }); + }); + + it('should inject the "source" option into the request', () => { + const result = { + _id: 'document-id', + _version: 1, + _source: { foo: 'bar' }, + created: false + }; + kuzzle.query.resolves({ result }); + const body = { + query: { + match: { foo: 'bar' } + }, + changes: { + bar: 'foo' + } + }; + + return kuzzle.document.updateByQuery('index', 'collection', body, { source: true }) + .then(res => { + should(kuzzle.query) + .be.calledOnce() + .be.calledWith({ + controller: 'document', + action: 'updateByQuery', + index: 'index', + collection: 'collection', + body, + source: true + }, { source: true }); + + should(res).be.equal(result); + }); + }); + }); + describe('validate', () => { it('should call document/validate query and return a Promise which resolves the validation result', () => { const result = { From ddde1ca48fa71cbcfae34e7b0cc28d41348308ae Mon Sep 17 00:00:00 2001 From: Yoann Abbes Date: Thu, 4 Jun 2020 18:09:54 +0200 Subject: [PATCH 02/10] fix test --- .ci/doc/templates/print-result-array.tpl.js | 1 - .../update-by-query/snippets/update-by-query.test.yml | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.ci/doc/templates/print-result-array.tpl.js b/.ci/doc/templates/print-result-array.tpl.js index 9619adede..587422d69 100644 --- a/.ci/doc/templates/print-result-array.tpl.js +++ b/.ci/doc/templates/print-result-array.tpl.js @@ -23,7 +23,6 @@ kuzzle.on('networkError', error => { } try { [snippet-code] - console.log(result.successes); for (const elem of result.successes) { console.log(elem); } diff --git a/doc/7/controllers/document/update-by-query/snippets/update-by-query.test.yml b/doc/7/controllers/document/update-by-query/snippets/update-by-query.test.yml index 49ad46eb0..1853c4fb3 100644 --- a/doc/7/controllers/document/update-by-query/snippets/update-by-query.test.yml +++ b/doc/7/controllers/document/update-by-query/snippets/update-by-query.test.yml @@ -11,9 +11,9 @@ hooks: for i in 1 2 3 4 5; do curl -H "Content-type: application/json" -d '{"capacity": 7}' kuzzle:7512/nyc-open-data/yellow-taxi/_create done - curl -XPOST kuzzle:7512/nyc-open-data/_refresh + curl -XPOST kuzzle:7512/nyc-open-data/yellow-taxi/_refresh after: template: print-result-array expected: - - "id: document_1, _version: 2, status: 200" - - "id: document_2, _version: 2, status: 200" \ No newline at end of file + - "{ _id: 'document_1', _version: 2, status: 200 }" + - "{ _id: 'document_2', _version: 2, status: 200 }" \ No newline at end of file From 1e44e97b36b73fbf31f94e85f26cc48eebd4aada Mon Sep 17 00:00:00 2001 From: Yoann Abbes Date: Fri, 5 Jun 2020 08:36:03 +0200 Subject: [PATCH 03/10] correct signature --- .../document/update-by-query/index.md | 2 +- .../snippets/update-by-query.js | 59 ++++++++++--------- src/controllers/Document.js | 4 +- test/controllers/document.test.js | 38 ++++++++---- 4 files changed, 63 insertions(+), 40 deletions(-) diff --git a/doc/7/controllers/document/update-by-query/index.md b/doc/7/controllers/document/update-by-query/index.md index e124bb807..89d737b24 100644 --- a/doc/7/controllers/document/update-by-query/index.md +++ b/doc/7/controllers/document/update-by-query/index.md @@ -16,7 +16,7 @@ An empty or null query will match all documents in the collection.
```js -updateByQuery(index, collection, body, [options]) +updateByQuery(index, collection, searchQuery, changes, [options]) ``` | Argument | Type | Description | diff --git a/doc/7/controllers/document/update-by-query/snippets/update-by-query.js b/doc/7/controllers/document/update-by-query/snippets/update-by-query.js index 9dd7caaff..0afd43b9e 100644 --- a/doc/7/controllers/document/update-by-query/snippets/update-by-query.js +++ b/doc/7/controllers/document/update-by-query/snippets/update-by-query.js @@ -1,30 +1,35 @@ -const result = await kuzzle.document.updateByQuery( - 'nyc-open-data', - 'yellow-taxi', - { - query: { - match: { - capacity: 4 +try { + result = await kuzzle.document.updateByQuery( + 'nyc-open-data', + 'yellow-taxi', + { + query: { + match: { + capacity: 4 + } } - }, - changes: { - capacity: 42 - } - }); + }, { + changes: { + capacity: 42 + } + }); /* { - successes: [ - { - _id: , - _source: // if source set to true - status: 200 - }, - { - _id: , - _source: // if source set to true - status: 200 - } - ], - errors: [] - } - */ \ No newline at end of file +successes: [ + { + _id: , + _source: // if source set to true + status: 200 + }, + { + _id: , + _source: // if source set to true + status: 200 + } + ], +errors: [] +} +*/ +} catch (error) { + console.log(error.message); +} diff --git a/src/controllers/Document.js b/src/controllers/Document.js index 4b8d84666..073dfa4c8 100644 --- a/src/controllers/Document.js +++ b/src/controllers/Document.js @@ -220,11 +220,11 @@ class DocumentController extends BaseController { .then(response => response.result); } - updateByQuery(index, collection, body, options = {}) { + updateByQuery(index, collection, searchQuery, changes, options = {}) { const request = { index, collection, - body, + body: {...searchQuery, ...changes}, action: 'updateByQuery', source: options.source }; diff --git a/test/controllers/document.test.js b/test/controllers/document.test.js index abdb1d6ab..c6ccfc5ad 100644 --- a/test/controllers/document.test.js +++ b/test/controllers/document.test.js @@ -556,7 +556,7 @@ describe('Document Controller', () => { body: { foo: 'bar' }, retryOnConflict: undefined, source: true - }, { source: true }); + }); should(res).be.equal(result); }); @@ -572,15 +572,17 @@ describe('Document Controller', () => { created: false }; kuzzle.query.resolves({ result }); - const body = { + const searchQuery = { query: { match: { foo: 'bar' } - }, + } + }; + const changes = { changes: { bar: 'foo' } }; - return kuzzle.document.updateByQuery('index', 'collection', body, options) + return kuzzle.document.updateByQuery('index', 'collection', searchQuery, changes, options) .then(res => { should(kuzzle.query) .be.calledOnce() @@ -589,7 +591,14 @@ describe('Document Controller', () => { action: 'updateByQuery', index: 'index', collection: 'collection', - body, + body: { + query: { + match: {foo: 'bar'} + }, + changes: { + bar: 'foo' + } + }, source: undefined }, options); @@ -605,16 +614,18 @@ describe('Document Controller', () => { created: false }; kuzzle.query.resolves({ result }); - const body = { + const searchQuery = { query: { match: { foo: 'bar' } - }, + } + }; + const changes = { changes: { bar: 'foo' } }; - return kuzzle.document.updateByQuery('index', 'collection', body, { source: true }) + return kuzzle.document.updateByQuery('index', 'collection', searchQuery, changes, { source: true }) .then(res => { should(kuzzle.query) .be.calledOnce() @@ -623,9 +634,16 @@ describe('Document Controller', () => { action: 'updateByQuery', index: 'index', collection: 'collection', - body, + body: { + query: { + match: { foo: 'bar' } + }, + changes: { + bar: 'foo' + } + }, source: true - }, { source: true }); + }); should(res).be.equal(result); }); From 935d121dace8c2cb6585feda5a3ca486f8f9a8be Mon Sep 17 00:00:00 2001 From: Yoann Abbes Date: Fri, 5 Jun 2020 08:39:51 +0200 Subject: [PATCH 04/10] doc --- .../controllers/document/update-by-query/index.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/7/controllers/document/update-by-query/index.md b/doc/7/controllers/document/update-by-query/index.md index 89d737b24..41e6469c4 100644 --- a/doc/7/controllers/document/update-by-query/index.md +++ b/doc/7/controllers/document/update-by-query/index.md @@ -46,18 +46,18 @@ Each updated document is an object of the `successes` array with the following p | Property | Type | Description | |------------- |--------------------------------------------- |--------------------------------- | -| `_source` |
ConcurrentHashMap
| Updated document (if `source` option set to true) | -| `_id` |
String
| ID of the udated document | -| `_version` |
Integer
| Version of the document in the persistent data storage | -| `status` |
Integer
| HTTP status code | +| `_source` |
object
| Updated document (if `source` option set to true) | +| `_id` |
string
| ID of the udated document | +| `_version` |
number
| Version of the document in the persistent data storage | +| `status` |
number
| HTTP status code | Each errored document is an object of the `errors` array with the following properties: | Property | Type | Description | |------------- |--------------------------------------------- |--------------------------------- | -| `document` |
ConcurrentHashMap
| Document that causes the error | -| `status` |
Integer
| HTTP error status | -| `reason` |
String
| Human readable reason | +| `document` |
object
| Document that causes the error | +| `status` |
number
| HTTP error status | +| `reason` |
string
| Human readable reason | ## Usage From ff21e7ad87532a68ff8a258fc94675b2039106e6 Mon Sep 17 00:00:00 2001 From: Yoann Abbes Date: Fri, 5 Jun 2020 08:58:29 +0200 Subject: [PATCH 05/10] forgot to commit template --- .ci/doc/templates/print-result-array.tpl.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.ci/doc/templates/print-result-array.tpl.js b/.ci/doc/templates/print-result-array.tpl.js index 587422d69..80e8cc8c3 100644 --- a/.ci/doc/templates/print-result-array.tpl.js +++ b/.ci/doc/templates/print-result-array.tpl.js @@ -16,19 +16,16 @@ kuzzle.on('networkError', error => { }); (async () => { + let result; try { await kuzzle.connect(); } catch (error) { console.log(`Can not connect to Kuzzle: ${error.message}`); } - try { - [snippet-code] - for (const elem of result.successes) { - console.log(elem); - } - } catch (error) { - console.error(error.message); - } finally { + [snippet-code] finally { kuzzle.disconnect(); } + for (const elem of result.successes) { + console.log(elem); + } })(); From 59216e48d4c676d718db800d5d71cfa5c142d7a1 Mon Sep 17 00:00:00 2001 From: Yoann Abbes Date: Fri, 5 Jun 2020 10:42:52 +0200 Subject: [PATCH 06/10] update codecov --- package-lock.json | 18 +++++++++--------- package.json | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 707a27796..93542cfea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1328,9 +1328,9 @@ "dev": true }, "@tootallnate/once": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.0.0.tgz", - "integrity": "sha512-KYyTT/T6ALPkIRd2Ge080X/BsXvy9O0hcWTtMWkPvwAwF99+vn6Dv4GzrFT/Nn1LePr+FFDbRXXlqmsy9lw2zA==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", + "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", "dev": true }, "@types/color-name": { @@ -2613,9 +2613,9 @@ "dev": true }, "codecov": { - "version": "3.6.5", - "resolved": "https://registry.npmjs.org/codecov/-/codecov-3.6.5.tgz", - "integrity": "sha512-v48WuDMUug6JXwmmfsMzhCHRnhUf8O3duqXvltaYJKrO1OekZWpB/eH6iIoaxMl8Qli0+u3OxptdsBOYiD7VAQ==", + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/codecov/-/codecov-3.7.0.tgz", + "integrity": "sha512-uIixKofG099NbUDyzRk1HdGtaG8O+PBUAg3wfmjwXw2+ek+PZp+puRvbTohqrVfuudaezivJHFgTtSC3M8MXww==", "dev": true, "requires": { "argv": "0.0.2", @@ -9509,9 +9509,9 @@ "dev": true }, "uuid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", "dev": true }, "v8-compile-cache": { diff --git a/package.json b/package.json index b4542688f..1e65fa2a7 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@babel/core": "^7.9.0", "@babel/preset-env": "^7.9.5", "babel-loader": "^8.1.0", - "codecov": "^3.6.5", + "codecov": "^3.7.0", "cucumber": "^6.0.5", "eslint": "^6.8.0", "eslint-friendly-formatter": "^4.0.1", From 70de6d060b13a2fac397257b568495fef61c40d5 Mon Sep 17 00:00:00 2001 From: Yoann Abbes Date: Fri, 5 Jun 2020 12:12:56 +0200 Subject: [PATCH 07/10] requested changes --- ...rray.tpl.js => print-result-successes.tpl.js} | 0 .../update-by-query/snippets/update-by-query.js | 10 +++------- .../snippets/update-by-query.test.yml | 2 +- src/controllers/Document.js | 2 +- test/controllers/document.test.js | 16 ++++------------ 5 files changed, 9 insertions(+), 21 deletions(-) rename .ci/doc/templates/{print-result-array.tpl.js => print-result-successes.tpl.js} (100%) diff --git a/.ci/doc/templates/print-result-array.tpl.js b/.ci/doc/templates/print-result-successes.tpl.js similarity index 100% rename from .ci/doc/templates/print-result-array.tpl.js rename to .ci/doc/templates/print-result-successes.tpl.js diff --git a/doc/7/controllers/document/update-by-query/snippets/update-by-query.js b/doc/7/controllers/document/update-by-query/snippets/update-by-query.js index 0afd43b9e..e4061f031 100644 --- a/doc/7/controllers/document/update-by-query/snippets/update-by-query.js +++ b/doc/7/controllers/document/update-by-query/snippets/update-by-query.js @@ -3,15 +3,11 @@ try { 'nyc-open-data', 'yellow-taxi', { - query: { - match: { - capacity: 4 - } + match: { + capacity: 4 } }, { - changes: { - capacity: 42 - } + capacity: 42 }); /* { diff --git a/doc/7/controllers/document/update-by-query/snippets/update-by-query.test.yml b/doc/7/controllers/document/update-by-query/snippets/update-by-query.test.yml index 1853c4fb3..a51c40859 100644 --- a/doc/7/controllers/document/update-by-query/snippets/update-by-query.test.yml +++ b/doc/7/controllers/document/update-by-query/snippets/update-by-query.test.yml @@ -13,7 +13,7 @@ hooks: done curl -XPOST kuzzle:7512/nyc-open-data/yellow-taxi/_refresh after: -template: print-result-array +template: print-result-successes expected: - "{ _id: 'document_1', _version: 2, status: 200 }" - "{ _id: 'document_2', _version: 2, status: 200 }" \ No newline at end of file diff --git a/src/controllers/Document.js b/src/controllers/Document.js index 073dfa4c8..6a25ed9bc 100644 --- a/src/controllers/Document.js +++ b/src/controllers/Document.js @@ -224,7 +224,7 @@ class DocumentController extends BaseController { const request = { index, collection, - body: {...searchQuery, ...changes}, + body: {query: searchQuery, changes}, action: 'updateByQuery', source: options.source }; diff --git a/test/controllers/document.test.js b/test/controllers/document.test.js index c6ccfc5ad..1e61df4a2 100644 --- a/test/controllers/document.test.js +++ b/test/controllers/document.test.js @@ -573,14 +573,10 @@ describe('Document Controller', () => { }; kuzzle.query.resolves({ result }); const searchQuery = { - query: { - match: { foo: 'bar' } - } + match: { foo: 'bar' } }; const changes = { - changes: { - bar: 'foo' - } + bar: 'foo' }; return kuzzle.document.updateByQuery('index', 'collection', searchQuery, changes, options) .then(res => { @@ -615,14 +611,10 @@ describe('Document Controller', () => { }; kuzzle.query.resolves({ result }); const searchQuery = { - query: { - match: { foo: 'bar' } - } + match: { foo: 'bar' } }; const changes = { - changes: { - bar: 'foo' - } + bar: 'foo' }; return kuzzle.document.updateByQuery('index', 'collection', searchQuery, changes, { source: true }) From 006a0a4361c8bb587a575183e987a1e86aeed58d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Cottinet?= Date: Sat, 6 Jun 2020 14:49:47 +0200 Subject: [PATCH 08/10] Update .ci/doc/templates/print-result-successes.tpl.js --- .ci/doc/templates/print-result-successes.tpl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/doc/templates/print-result-successes.tpl.js b/.ci/doc/templates/print-result-successes.tpl.js index 80e8cc8c3..8eea2443a 100644 --- a/.ci/doc/templates/print-result-successes.tpl.js +++ b/.ci/doc/templates/print-result-successes.tpl.js @@ -10,7 +10,7 @@ const new WebSocket('kuzzle', { autoReconnect: false }) ); -// Adds a listener to detect any connection problems +// Adds a listener to detect connection problems kuzzle.on('networkError', error => { console.error(`Network Error: ${error.message}`); }); From 6a15de2d99140901faf41c72b093c7d5c0cbb303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Cottinet?= Date: Sat, 6 Jun 2020 14:49:53 +0200 Subject: [PATCH 09/10] Update .ci/doc/templates/print-result-successes.tpl.js --- .ci/doc/templates/print-result-successes.tpl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/doc/templates/print-result-successes.tpl.js b/.ci/doc/templates/print-result-successes.tpl.js index 8eea2443a..92dca79e5 100644 --- a/.ci/doc/templates/print-result-successes.tpl.js +++ b/.ci/doc/templates/print-result-successes.tpl.js @@ -20,7 +20,7 @@ kuzzle.on('networkError', error => { try { await kuzzle.connect(); } catch (error) { - console.log(`Can not connect to Kuzzle: ${error.message}`); + console.log(`Cannot connect to Kuzzle: ${error.message}`); } [snippet-code] finally { kuzzle.disconnect(); From 6fa824039d0b14dc29773e53d17fa73e704f04a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Cottinet?= Date: Sat, 6 Jun 2020 14:50:01 +0200 Subject: [PATCH 10/10] Update doc/7/controllers/document/update-by-query/snippets/update-by-query.js --- .../snippets/update-by-query.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/7/controllers/document/update-by-query/snippets/update-by-query.js b/doc/7/controllers/document/update-by-query/snippets/update-by-query.js index e4061f031..ec7994850 100644 --- a/doc/7/controllers/document/update-by-query/snippets/update-by-query.js +++ b/doc/7/controllers/document/update-by-query/snippets/update-by-query.js @@ -12,17 +12,17 @@ try { /* { successes: [ - { - _id: , - _source: // if source set to true - status: 200 - }, - { - _id: , - _source: // if source set to true - status: 200 - } - ], + { + _id: , + _source: // if source set to true + status: 200 + }, + { + _id: , + _source: // if source set to true + status: 200 + } +], errors: [] } */