Skip to content

Commit db5976a

Browse files
committed
return string only when a string is supplied, jsdoc #42
1 parent 4910f8f commit db5976a

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

lib/documents.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ function removeOutputTransform(headers, data) {
10661066

10671067
if (operation.contentOnly === true) {
10681068
// for deprecated backward compatibility
1069-
return (operation.uris.length === 1) ? operation.uris[0] : operation.uris;
1069+
return operation.isLegacy ? operation.uris[0] : operation.uris;
10701070
}
10711071

10721072
var wrapper = {
@@ -1108,9 +1108,11 @@ function removeOutputTransform(headers, data) {
11081108
* a {@link documents#removeResult} success callback.
11091109
*/
11101110
function removeDocument() {
1111-
return removeDocumentImpl.call(this, false, mlutil.asArray.apply(null, arguments));
1111+
return removeDocumentImpl.call(
1112+
this, false, false, mlutil.asArray.apply(null, arguments)
1113+
);
11121114
}
1113-
function removeDocumentImpl(contentOnly, args) {
1115+
function removeDocumentImpl(contentOnly, isLegacy, args) {
11141116
if (args.length < 1) {
11151117
throw new Error('must provide uris for document remove()');
11161118
}
@@ -1178,6 +1180,7 @@ function removeDocumentImpl(contentOnly, args) {
11781180
operation.outputTransform = removeOutputTransform;
11791181
operation.errorTransform = uriErrorTransform;
11801182
operation.contentOnly = (contentOnly === true);
1183+
operation.isLegacy = isLegacy;
11811184

11821185
return mlrest.startRequest(operation);
11831186
}

lib/marklogic.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,11 +442,18 @@ MarkLogicClient.prototype.read = readClient;
442442
* @param {string|string[]} uris - the uri string or an array of uri strings
443443
* identifying the database documents
444444
* @returns {ResultProvider} an object whose result() function takes
445-
* a success callback that receives the uri string or an array of uris strings
446-
* identifying the removed documents.
445+
* a success callback that receives the uris identifying the removed documents.
446+
* For backward compatibility, if a string ispassed, the uri is returned
447+
* as a string, but in the next major release, the uri will be return
448+
* as an array with one string.
447449
*/
448450
function removeClient() {
449-
return documents.removeImpl.call(this.documents, true, mlutil.asArray.apply(null, arguments));
451+
return documents.removeImpl.call(
452+
this.documents,
453+
true,
454+
(arguments.length === 1 && valcheck.isString(arguments[0])),
455+
mlutil.asArray.apply(null, arguments)
456+
);
450457
}
451458
MarkLogicClient.prototype.remove = removeClient;
452459
/**

0 commit comments

Comments
 (0)