Skip to content

Accounting for if docs exist before calling 'dataByKey' #67

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change History

## v1.3.9 2022-06-27

- Fixed errors being thrown when unsetting if documents do not exist
- Ref: https://github.com/robfallows/tunguska-reactive-aggregate/issues/61

## v1.3.8 2022-06-06

- Added [options.specificWarnings](https://github.com/robfallows/tunguska-reactive-aggregate/pull/65)
Expand Down
4 changes: 3 additions & 1 deletion aggregate.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ export const ReactiveAggregate = (sub, collection = null, pipeline = [], options
} else {
if (sub._session.collectionViews instanceof Map) {
// Since the pipeline fields might have been removed, we need to find the differences and define them as 'undefined' so the sub removes them.
const previousFields = [...sub._session.collectionViews.get(localOptions.clientCollection).documents.get(doc_id).dataByKey.keys()];

const previousDocs = sub._session.collectionViews.get(localOptions.clientCollection).documents;
const previousFields = [previousDocs && previousDocs.get(doc_id).dataByKey.keys()];
previousFields.forEach(field => {
// At this point they are undefined because they no longer exist in the new doc, they're not literally set as undefined
if (doc[field] === undefined) {
Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
name: 'tunguska:reactive-aggregate',
version: '1.3.8',
version: '1.3.9',
summary: 'Publish aggregations reactively',
git: 'https://github.com/robfallows/tunguska-reactive-aggregate',
documentation: 'README.md'
Expand Down