Skip to content

Commit

Permalink
Removes unnecessary ANDs
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidJGapCR committed Oct 31, 2023
1 parent d867e8c commit 84b9642
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,9 @@ export async function lockDocuments(

await concurrencyCollection.deleteMany(
{
$and: [
{
_id: {
$in: documentUuids,
},
},
],
_id: {
$in: documentUuids,
},
},
{ session },
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,11 @@ async function updateAllowingIdentityChange(
const referringDocumentUuids: WithId<MeadowlarkDocument>[] = await mongoCollection
.find(
{
$and: [
{
aliasMeadowlarkIds: {
$in: document.outboundRefs,
},
},
],
aliasMeadowlarkIds: {
$in: document.outboundRefs,
},
},

{ projection: { documentUuid: 1 } },
)
.toArray();
Expand Down Expand Up @@ -265,13 +262,9 @@ async function updateDisallowingIdentityChange(
const referringDocumentUuids: WithId<MeadowlarkDocument>[] = await mongoCollection
.find(
{
$and: [
{
aliasMeadowlarkIds: {
$in: document.outboundRefs,
},
},
],
aliasMeadowlarkIds: {
$in: document.outboundRefs,
},
},
{ projection: { documentUuid: 1 } },
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,9 @@ export async function upsertDocumentTransaction(
const referringDocumentUuids: WithId<MeadowlarkDocument>[] = await mongoCollection
.find(
{
$and: [
{
aliasMeadowlarkIds: {
$in: document.outboundRefs,
},
},
],
aliasMeadowlarkIds: {
$in: document.outboundRefs,
},
},
{ projection: { documentUuid: 1 } },
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@ describe('when lockDocuments is called with a given number of documents', () =>

it('concurrencyCollection should be empty after the function is called', async () => {
const documents = await getConcurrencyCollection(client).countDocuments({
$and: [
{
meadowlarkId: {
$in: ['123', '456'],
},
},
],
meadowlarkId: {
$in: ['123', '456'],
},
});

expect(documents).toBe(0);
Expand Down

0 comments on commit 84b9642

Please sign in to comment.