Skip to content

Commit

Permalink
fix(easy-mongo): rolling back the changes on isIn and notIn in Stages…
Browse files Browse the repository at this point in the history
….ts (were triggering alternative behavior in MongoDB)
  • Loading branch information
aahoogendoorn committed Jan 8, 2024
1 parent 485f54f commit 2a68bd5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 28 deletions.
4 changes: 2 additions & 2 deletions packages/easy-mongo/src/Stages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ export const stages = {
gte: (value: Filter) => ({ $gte: value }),
lt: (value: Filter) => ({ $lt: value }),
lte: (value: Filter) => ({ $lte: value }),
isIn: (value: OneOrMore<unknown>, separator = ',') => ifNotEmpty(value, v => ({ $in: isString(v) ? v.split(separator) : v })),
notIn: (value: OneOrMore<unknown>, separator = ',') => ifNotEmpty(value, v => ({ $nin: isString(v) ? v.split(separator) : v })),
isIn: (value: OneOrMore<unknown>, separator = ',') => ({ $in: isString(value) ? value.split(separator) : value }),
notIn: (value: OneOrMore<unknown>, separator = ',') => ({ $nin: isString(value) ? value.split(separator) : value }),
after: (date: unknown) => stages.match.gte(toMongoType(date)),
before: (date: unknown) => stages.match.lt(toMongoType(date)),
anywhere: (q: string) => ({ $regex: escapeRegex(q), $options: 'i' }),
Expand Down
26 changes: 0 additions & 26 deletions packages/easy-mongo/test/Stages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,6 @@ describe('Stages', () => {
});
});

test('isIn if undefined', () => {
expect(match({ classicId: isIn(undefined as unknown as string) })).toStrictEqual({
$match: { },
});
});

test('isIn from empty string', () => {
expect(match({ classicId: isIn('') })).toStrictEqual({
$match: { },
});
});

test('isIn from string', () => {
expect(match({ classicId: isIn('3,4') })).toStrictEqual({
$match: { classicId: { $in: ['3', '4'] } },
Expand All @@ -113,20 +101,6 @@ describe('Stages', () => {
});
});


test('notIn if undefined', () => {
expect(match({ classicId: notIn(undefined as unknown as string) })).toStrictEqual({
$match: { },
});
});

test('notIn from empty string', () => {
expect(match({ classicId: notIn('') })).toStrictEqual({
$match: { },
});
});


test('notIn from string', () => {
expect(match({ classicId: notIn('3,4') })).toStrictEqual({
$match: { classicId: { $nin: ['3', '4'] } },
Expand Down

0 comments on commit 2a68bd5

Please sign in to comment.