Skip to content

Commit

Permalink
Fix wrong return value from collection:truncate (#1380)
Browse files Browse the repository at this point in the history
Currently collection:truncate returns the list of deleted document IDs.
This PR change the return value to match the documentation with { acknowledged: true }
  • Loading branch information
Aschen authored and Yoann-Abbes committed Aug 20, 2019
1 parent 6ca80dc commit 5431976
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/api/controllers/collectionController.js
Expand Up @@ -262,16 +262,16 @@ class CollectionController extends BaseController {
truncate(request) {
assertHasIndexAndCollection(request);

return this.engine.truncateCollection(request);
return this.engine.truncateCollection(request)
.then(() => ({ acknowledged: true }));
}

/**
* @param {Request} request
* @returns {Promise<Object>}
*/
list(request) {
const
type = request.input.args.type ? request.input.args.type : 'all';
const type = request.input.args.type || 'all';

assertHasIndex(request);

Expand All @@ -283,7 +283,7 @@ class CollectionController extends BaseController {

if (type === 'realtime' || type === 'all') {
collections = this.kuzzle.hotelClerk.getRealtimeCollections(
request.input.resource.index).map(name => ({name, type: 'realtime'}));
request.input.resource.index).map(name => ({ name, type: 'realtime' }));
}

return Bluebird.resolve()
Expand Down
2 changes: 1 addition & 1 deletion test/api/controllers/collectionController.test.js
Expand Up @@ -91,7 +91,7 @@ describe('Test: collection controller', () => {
should(truncate).be.calledWith(request);

should(response).be.instanceof(Object);
should(response).match(foo);
should(response).match({ acknowledged: true });
});
});
});
Expand Down

0 comments on commit 5431976

Please sign in to comment.