ravendb
Version:
RavenDB client for Node.js
40 lines • 1.93 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocumentSessionAttachments = void 0;
const DocumentSessionAttachmentsBase_js_1 = require("./DocumentSessionAttachmentsBase.js");
const HeadAttachmentCommand_js_1 = require("../Commands/HeadAttachmentCommand.js");
const GetAttachmentOperation_js_1 = require("../Operations/Attachments/GetAttachmentOperation.js");
class DocumentSessionAttachments extends DocumentSessionAttachmentsBase_js_1.DocumentSessionAttachmentsBase {
constructor(session) {
super(session);
}
async exists(documentId, name) {
const command = new HeadAttachmentCommand_js_1.HeadAttachmentCommand(documentId, name, null);
this._session.incrementRequestCount();
await this._requestExecutor.execute(command, this._sessionInfo);
return !!command.result;
}
async get(idOrEntity, name) {
let docId;
if (typeof idOrEntity !== "string") {
const document = this._session.documentsByEntity.get(idOrEntity);
if (!document) {
this._throwEntityNotInSessionOrMissingId(idOrEntity);
}
docId = document.id;
}
else {
docId = idOrEntity;
}
const operation = new GetAttachmentOperation_js_1.GetAttachmentOperation(docId, name, "Document", null);
this._session.incrementRequestCount();
return await this._session.operations.send(operation, this._sessionInfo);
}
async getRevision(documentId, name, changeVector) {
const operation = new GetAttachmentOperation_js_1.GetAttachmentOperation(documentId, name, "Revision", changeVector);
this._session.incrementRequestCount();
return this._session.operations.send(operation, this._sessionInfo);
}
}
exports.DocumentSessionAttachments = DocumentSessionAttachments;
//# sourceMappingURL=DocumentSessionAttachments.js.map