Support for filter by parent document (#6850)
* Backend support for filter by parent document * parentDocumentId -> documentId
This commit is contained in:
@@ -785,6 +785,7 @@ router.post(
|
||||
const {
|
||||
query,
|
||||
collectionId,
|
||||
documentId,
|
||||
userId,
|
||||
dateFilter,
|
||||
statusFilter = [],
|
||||
@@ -853,6 +854,18 @@ router.post(
|
||||
authorize(user, "readDocument", collection);
|
||||
}
|
||||
|
||||
let documentIds = undefined;
|
||||
if (documentId) {
|
||||
const document = await Document.findByPk(documentId, {
|
||||
userId: user.id,
|
||||
});
|
||||
authorize(user, "read", document);
|
||||
documentIds = [
|
||||
documentId,
|
||||
...(await document.findAllChildDocumentIds()),
|
||||
];
|
||||
}
|
||||
|
||||
let collaboratorIds = undefined;
|
||||
|
||||
if (userId) {
|
||||
@@ -862,6 +875,7 @@ router.post(
|
||||
response = await SearchHelper.searchForUser(user, query, {
|
||||
collaboratorIds,
|
||||
collectionId,
|
||||
documentIds,
|
||||
dateFilter,
|
||||
statusFilter,
|
||||
offset,
|
||||
|
||||
@@ -153,6 +153,9 @@ export const DocumentsSearchSchema = BaseSchema.extend({
|
||||
/** Filter results based on user */
|
||||
userId: z.string().uuid().optional(),
|
||||
|
||||
/** Filter results based on content within a document and it's children */
|
||||
documentId: z.string().uuid().optional(),
|
||||
|
||||
/**
|
||||
* Whether to include archived documents in results
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user