Skip to content

Commit 64806e7

Browse files
committed
fix mXXX routes return
1 parent ba87c96 commit 64806e7

File tree

13 files changed

+57
-44
lines changed

13 files changed

+57
-44
lines changed

.ci/doc/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ services:
1515
# - kuzzle_services__internalCache__node__host=redis
1616
# - kuzzle_services__memoryStorage__node__host=redis
1717
# - kuzzle_services__storageEngine__commonMapping__dynamic=true
18+
# - kuzzle_services__storageEngine__internalIndex__collections__users__dynamic=true
1819
# - NODE_ENV=production
1920

2021
# redis:

doc/7/controllers/bulk/import/index.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ Create, update or delete large amount of documents as fast as possible.
1111

1212
This route is faster than the `document:m*` routes family (e.g. [document:mCreate](/sdk/js/6/controllers/document/m-create)), but no real-time notifications will be generated, even if some of the documents in the import match subscription filters.
1313

14-
If some documents actions fail, the client will receive a [PartialError](/core/1/api/essentials/errors#partialerror) error.
15-
1614
<br/>
1715

1816
```js
@@ -70,16 +68,23 @@ Resolves to an object containing 2 properties:
7068

7169
| Property | Type | Description |
7270
| -------- | ------------------- | --------------------------------------------------- |
73-
| `errors` | <pre>boolean</pre> | `true` if there is some errors with the import |
74-
| `items` | <pre>object[]</pre> | Array of object containing document import statuses |
71+
| `successes` | <pre>object[]</pre> | Array of object containing successful document import |
72+
| `errors` | <pre>object[]</pre> | Array of object containing failed document import |
73+
74+
Each item of the `successes` array is an object containing the action name as key and the corresponding object contain the following properties:
75+
76+
| Property | Type | Description |
77+
| -------- | ------------------- | --------------------------------------------------- |
78+
| `_id` | <pre>String</pre> | Document unique identifier |
79+
| `status` | <pre>String</pre> | HTTP status code for that query |
7580

76-
Each item is an object containing the action name as key and the corresponding object contain the following properties:
81+
Each item of the `successes` array is an object containing the action name as key and the corresponding object contain the following properties:
7782

7883
| Property | Type | Description |
7984
| -------- | ------------------- | --------------------------------------------------- |
8085
| `_id` | <pre>String</pre> | Document unique identifier |
8186
| `status` | <pre>String</pre> | HTTP status code for that query |
82-
| `error` | <pre>Object</pre> | Error object if `status` >= `400` |
87+
| `error` | <pre>Object</pre> | Error object |
8388

8489
Each error object contain the following properties:
8590

doc/7/controllers/bulk/import/snippets/import.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ try {
1414
console.log(response);
1515
/*
1616
{ errors: false,
17-
items:
17+
successes:
1818
[ {
1919
index: {
2020
_id: "hQ10_GwBB2Y5786Pu_NO",
@@ -34,7 +34,7 @@ try {
3434
}
3535
} ] }
3636
*/
37-
const successfulImport = response.items.filter(item => {
37+
const successfulImport = response.successes.filter(item => {
3838
return Object.values(item)[0].status < 400;
3939
});
4040

doc/7/controllers/bulk/mWrite/index.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,24 @@ Additional query options
5353

5454
## Resolves
5555

56-
Returns a `hits` array, containing the list of created documents, in the same order than the one provided in the query.
56+
Returns an object containing 2 arrays: `successes` and `errors`
5757

58-
Each created document is an object with the following properties:
58+
Each created or replaced document is an object of the `successes` array with the following properties:
5959

60-
| Name | Type | Description |
61-
| --------- | ----------------- | ------------------- |
62-
| `_id` | <pre>string</pre> | ID of the newly created document |
60+
| Name | Type | Description |
61+
| --------- | ----------------- | ------------------------------------------------------ |
62+
| `_id` | <pre>string</pre> | Document ID |
6363
| `_version` | <pre>number</pre> | Version of the document in the persistent data storage |
64-
| `_source` | <pre>object</pre> | Created document |
64+
| `_source` | <pre>object</pre> | Document content |
65+
| `created` | <pre>boolean</pre> | True if the document was created |
6566

66-
If one or more document creations fail, the promise is rejected and the `error` object contains a [partial error](/core/1/api/essentials/errors#partialerror) error.
67+
Each errored document is an object of the `errors` array with the following properties:
68+
69+
| Name | Type | Description |
70+
| --------- | ----------------- | ------------------------------------------------------ |
71+
| `document` | <pre>object</pre> | Document that cause the error |
72+
| `status` | <pre>number</pre> | HTTP error status |
73+
| `reason` | <pre>string</pre> | Human readable reason |
6774

6875
## Usage
6976

doc/7/controllers/bulk/mWrite/snippets/mWrite.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ try {
2323

2424
console.log(result);
2525
/*
26-
{ hits:
26+
{ successes:
2727
[ { _id: 'panipokari',
2828
_source: {
2929
"licence": "B",
@@ -41,7 +41,7 @@ try {
4141
total: 2 }
4242
*/
4343

44-
console.log(`Document creator is ${result.hits[1]._source._kuzzle_info.creator}`);
44+
console.log(`Document creator is ${result.successes[1]._source._kuzzle_info.creator}`);
4545
} catch (error) {
4646
console.error(error.message);
4747
}

doc/7/controllers/document/m-create-or-replace/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ Additional query options
3535

3636
## Resolves
3737

38-
Returns an object containing 2 arrays: `hits` and `errors`
38+
Returns an object containing 2 arrays: `successes` and `errors`
3939

40-
Each created or replaced document is an object of the `hits` array with the following properties:
40+
Each created or replaced document is an object of the `successes` array with the following properties:
4141

4242
| Name | Type | Description |
4343
| --------- | ----------------- | ------------------------------------------------------ |

doc/7/controllers/document/m-create-or-replace/snippets/m-create-or-replace.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ try {
1919
console.log(response);
2020
/*
2121
{
22-
"hits": [
22+
"successes": [
2323
{
2424
"_id": "some-id",
2525
"_version": 1,
@@ -54,7 +54,7 @@ try {
5454
"errors": []
5555
}
5656
*/
57-
console.log(`Successfully createOrReplace ${response.hits.length} documents`);
57+
console.log(`Successfully createOrReplace ${response.successes.length} documents`);
5858
} catch (error) {
5959
console.error(error.message);
6060
}

doc/7/controllers/document/m-create/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ Additional query options
3333

3434
## Resolves
3535

36-
Returns an object containing 2 arrays: `hits` and `errors`
36+
Returns an object containing 2 arrays: `successes` and `errors`
3737

38-
Each created document is an object of the `hits` array with the following properties:
38+
Each created document is an object of the `successes` array with the following properties:
3939

4040
| Name | Type | Description |
4141
| --------- | ----------------- | ------------------------------------------------------ |

doc/7/controllers/document/m-create/snippets/m-create.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ try {
1717
console.log(response);
1818
/*
1919
{
20-
"hits": [
20+
"successes": [
2121
{
2222
"_id": "some-id",
2323
"_version": 1,
@@ -54,7 +54,7 @@ try {
5454
"errors": []
5555
}
5656
*/
57-
console.log(`Successfully created ${response.hits.length} documents`);
57+
console.log(`Successfully created ${response.successes.length} documents`);
5858
} catch (error) {
5959
console.error(error.message);
6060
}

doc/7/controllers/document/m-replace/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ Additional query options
3535

3636
## Resolves
3737

38-
Returns an object containing 2 arrays: `hits` and `errors`
38+
Returns an object containing 2 arrays: `successes` and `errors`
3939

40-
Each replaced document is an object of the `hits` array with the following properties:
40+
Each replaced document is an object of the `successes` array with the following properties:
4141

4242
| Name | Type | Description |
4343
| --------- | ----------------- | ------------------------------------------------------ |

0 commit comments

Comments
 (0)