Skip to content

Conversation

jankapunkt
Copy link
Collaborator

@jankapunkt jankapunkt commented Aug 12, 2018

Related to #43

The code is now first attempting to retrieve the underlying Mongo.Collection without directly accessing the filesCollection reference:

const mongoCollection = Mongo.Collection.get
  ? Mongo.Collection.get(this.data.atts.collection)
  : Meteor.connection._mongo_livedata_collections[this.data.atts.collection]

If the mongoCollection is present the filesCollection reference will be assigned to this.collection otherwise a lookup in the global scope is performed.

this.collection = mongoCollection
  ? mongoCollection.filesCollection
  : global[this.data.atts.collection]

In worst case this.collection is null, which will causes the already implemented 404 Error on line 46 to throw:

if (!this.collection) {
  throw new Meteor.Error(404, '[meteor-autoform-files] No such collection "' + this.data.atts.collection + '"');
}

This should give developers a more accurate information on the issue than the previous TypeError

@dr-dimitru
Copy link
Member

@jankapunkt thank you a lot for this PR. 👍

dr-dimitru added a commit that referenced this pull request Aug 14, 2018
 - Merge #44 , fixing #43 , thanks to @jankapunkt and @rich-m21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants