Skip to content

Commit

Permalink
🚧 progress: Squash.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Jun 4, 2024
1 parent 700684c commit a4392da
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions imports/api/query/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,20 @@ const _watchInit = async <T extends Document, U = T>(
sessionOptions,
);

const _filterToMatch = <T>(filter: Filter<T>) =>
const _filterToFullDocumentFilter = <T>(filter: Filter<T>) =>
Object.fromEntries(
Object.entries(filter).map(([key, value]) => [

Check warning on line 45 in imports/api/query/watch.ts

View check run for this annotation

Codecov / codecov/patch

imports/api/query/watch.ts#L43-L45

Added lines #L43 - L45 were not covered by tests
key.startsWith('$') ? key : `fullDocument.${key}`,
isObject(value) ? _filterToMatch(value as Filter<T>) : value,
isObject(value) ? _filterToFullDocumentFilter(value as Filter<T>) : value,
]),
);

const _filterToMatch = <T>(filter: Filter<T>) => ({

Check warning on line 51 in imports/api/query/watch.ts

View check run for this annotation

Codecov / codecov/patch

imports/api/query/watch.ts#L48-L51

Added lines #L48 - L51 were not covered by tests
$match: {
$and: _filterToFullDocumentFilter(filter),

Check warning on line 53 in imports/api/query/watch.ts

View check run for this annotation

Codecov / codecov/patch

imports/api/query/watch.ts#L53

Added line #L53 was not covered by tests
},
});

const _filterToPipeline = <T>({$text, ...rest}: Filter<T>) => {
return {
pipeline: [_filterToMatch(rest as Filter<T>)].filter(Boolean),
Expand Down

0 comments on commit a4392da

Please sign in to comment.