deleteDocument method
DELETE's the specified document. Must have a revision. If preserve is set to true the whole document is preserved and marked as deleted otherwise only a stub document is kept. Default is to not preserve.
Implementation
Future<dynamic> deleteDocument(String? id, String? rev,
[bool preserve = false]) {
if ((id == null) || (rev == null)) {
return _raiseException(WiltException.deleteDocNoIdRev);
}
final completer = Completer<dynamic>();
// Check the preserve flag
if (preserve) {
getDocument(id).then((dynamic res) {
if (res != null) {
dynamic resp = res.jsonCouchResponse;
resp = WiltUserUtils.addDocumentDeleteJo(resp);
putDocument(id, resp).then(completer.complete);
} else {
completer.complete(null);
}
});
return completer.future;
} else {
var url = id;
url = _setURLParameter(url, 'rev', rev);
url = _conditionUrl(url);
return _httpRequest('DELETE_DOCUMENT', url);
}
}