Skip to content

Commit

Permalink
feat: make find api backward compatible
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe committed Mar 4, 2024
1 parent 77de5b9 commit 1cd4c2d
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ export function getQueryParams({
shouldClause.push(permissionDSL.query);
}

if (ACLSearchParams.workspaces) {
if (ACLSearchParams.workspaces?.length) {
shouldClause.push({
terms: {
workspaces: ACLSearchParams.workspaces,
Expand All @@ -301,7 +301,28 @@ export function getQueryParams({
if (shouldClause.length) {
bool.filter.push({
bool: {
should: shouldClause,
should: [
/**
* Return those objects without workspaces field and permissions field to keep find find API backward compatible
*/
{
bool: {
must_not: [
{
exists: {
field: 'workspaces',
},
},
{
exists: {
field: 'permissions',
},
},
],
},
},
...shouldClause,
],
},
});
}
Expand Down

0 comments on commit 1cd4c2d

Please sign in to comment.