Skip to content

Commit

Permalink
feat: allow returning metadata for getDocuments (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
rombat committed Jan 15, 2024
1 parent 16d8fe3 commit c5dfded
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions services/docs/lib/services/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ module.exports.getDocuments = async function (resource, filter, user, query, sta
const dbQuery = Object.assign(filterState, filter, builder.find(queryBuilderOptions));

const dbFields = { _id: 1, states: 1, users: 1, groups: 1 };
if (query?.with?.includes('metadata')) {
dbFields.metadata = 1;
}

const aggregate = !!resource.isInheritable || query?.with?.includes('creator');

Expand Down Expand Up @@ -290,6 +293,9 @@ module.exports.getDocuments = async function (resource, filter, user, query, sta
if (query?.with?.includes('creator')) {
returnData.creator = doc.creator;
}
if (query?.with?.includes('metadata')) {
returnData.metadata = doc.metadata;
}

addVirtualProperties(resource, returnData.data);

Expand Down

0 comments on commit c5dfded

Please sign in to comment.