Skip to content

Commit

Permalink
Changes to support on production
Browse files Browse the repository at this point in the history
  • Loading branch information
rashmiangadi11 committed May 6, 2024
1 parent f9e1a61 commit 6c09bae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
6 changes: 3 additions & 3 deletions lib/persistence/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const cds = require("@sap/cds/lib");
const { SELECT } = cds.ql;

async function getDraftAttachments(queryFields, attachments, req) {
async function getDraftAttachments(attachments, req) {
const up_ = attachments.keys.up_.keys[0].$generatedFieldName;
const idValue = up_.split("__")[1];
return await SELECT(queryFields)
return await SELECT("filename", "mimeType", "content", "url", "ID")
.from(attachments.drafts)
.where({ up_: req.data[idValue] })
.where({ [up_]: req.data[idValue] })
.and({ HasActiveEntity: { "<>": 1 } });
}

Expand Down
12 changes: 0 additions & 12 deletions lib/sdm.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ module.exports = class SDMAttachmentsService extends (
async draftSaveHandler(req) {
const attachments =
cds.model.definitions[req.query.target.name + ".attachments"];
const queryFields = this.getFields(attachments);
const attachment_val = await getDraftAttachments(
queryFields,
attachments,
req
);
Expand Down Expand Up @@ -82,16 +80,6 @@ module.exports = class SDMAttachmentsService extends (
return duplicateFilesErrMsg;
}

getFields(attachments) {
const attachmentFields = ["filename", "mimeType", "content", "url", "ID"];
const { up_ } = attachments.keys;
if (up_)
return up_.keys
.map((k) => "up__" + k.ref[0])
.concat(...attachmentFields)
.map((k) => ({ ref: [k] }));
else return Object.keys(attachments.keys);
}

async attachDeletionData(req) {
const attachments =
Expand Down

0 comments on commit 6c09bae

Please sign in to comment.