-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PIN-6002 - Listing templates #1463
base: feature/pin-4901_e-service-template
Are you sure you want to change the base?
PIN-6002 - Listing templates #1463
Conversation
$nor: [ | ||
{ | ||
$and: [ | ||
{ "data.creatorId": { $ne: authData.organizationId } }, | ||
{ "data.versions": { $size: 0 } }, | ||
], | ||
}, | ||
{ | ||
$and: [ | ||
{ "data.creatorId": { $ne: authData.organizationId } }, | ||
{ "data.versions": { $size: 1 } }, | ||
{ | ||
"data.versions.state": { | ||
$eq: eserviceTemplateVersionState.draft, | ||
}, | ||
}, | ||
], | ||
}, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this filter quite confusing. I'm trying to understand it by reading the SRS and I suppose that this is the filter to remove draft versions if the caller is not the creator. Am I correct? In that case, Couldn't the filter be simplified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I semplified the whole query as such:
{
$nor: [
{
"data.creatorId": { $ne: authData.organizationId },
"data.versions": { $size: 1 },
"data.versions.state": eserviceTemplateVersionState.draft,
},
],
}
: {
$nor: [
{
"data.versions": { $size: 1 },
"data.versions.state": {
$eq: eserviceTemplateVersionState.draft,
},
},
],
};
I removed the check for the empty version arra, it could never happed with our actual implementation.
LMK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still confused. Why are you using nor
with only one expression inside?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be wrong but I think that's the only way to have a "$not" operator at that level on documentDB
Closes PIN-6002
Merge after #1443