UNPKG

ravendb

Version:
51 lines 1.73 kB
import { StringUtil } from "../../../Utility/StringUtil.js"; import { throwError } from "../../../Exceptions/index.js"; import { RavenCommand } from "../../../Http/RavenCommand.js"; export class DeleteAttachmentOperation { _documentId; _name; _changeVector; get resultType() { return "CommandResult"; } constructor(documentId, name, changeVector) { this._documentId = documentId; this._name = name; this._changeVector = changeVector; } getCommand(store, conventions, httpCache) { return new DeleteAttachmentCommand(this._documentId, this._name, this._changeVector); } } export class DeleteAttachmentCommand extends RavenCommand { _documentId; _name; _changeVector; constructor(documentId, name, changeVector) { super(); if (StringUtil.isNullOrWhitespace(documentId)) { throwError("InvalidArgumentException", "DocumentId cannot be null or empty"); } if (StringUtil.isNullOrWhitespace(name)) { throwError("InvalidArgumentException", "Name cannot be null or empty"); } this._documentId = documentId; this._name = name; this._changeVector = changeVector; } get isReadRequest() { return false; } createRequest(node) { const uri = node.url + "/databases/" + node.database + "/attachments?id=" + encodeURIComponent(this._documentId) + "&name=" + encodeURIComponent(this._name); const req = { uri, method: "DELETE" }; this._addChangeVectorIfNotNull(this._changeVector, req); return req; } } //# sourceMappingURL=DeleteAttachmentOperation.js.map