Skip to content
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

Error: There is already a collection named "jobQueue" #252

Open
holmrenser opened this issue Jul 28, 2017 · 1 comment
Open

Error: There is already a collection named "jobQueue" #252

holmrenser opened this issue Jul 28, 2017 · 1 comment
Labels

Comments

@holmrenser
Copy link

As per the example I am running the following client-side code:

I have a button that submits a job

Template.feature.events({
  'click #submit': function(event,template){
    const jobQueue = JobCollection('jobQueue', { noCollectionSuffix: true });
    const job = new Job(jobQueue, 'test-job', { Id: this.ID })
    job.priority('normal').save()
  }
});

When doing this I run into the following error if I click the button more than once:

Error: There is already a collection named "jobQueue"
    at JobCollection.Mongo.Collection (collection.js:226)
    at JobCollectionBase [as constructor] (shared.coffee:132)
    at new JobCollection (client.coffee:37)
    at JobCollection (client.coffee:34)
    at Blaze.TemplateInstance.<anonymous> (feature.js:110)
    at blaze.js?hash=f33d3df…:3398
    at Function.Template._withTemplateInstanceFunc (blaze.js?hash=f33d3df…:3744)
    at fireCallbacks (blaze.js?hash=f33d3df…:3394)
    at Blaze.View.<anonymous> (blaze.js?hash=f33d3df…:3474)
    at fireCallbacks (blaze.js?hash=f33d3df…:2014)
@vsivsi
Copy link
Owner

vsivsi commented Jul 31, 2017

Hi, don't instantiate a new collection with every click.

Move this code outside of your event handler:

const jobQueue = JobCollection('jobQueue', { noCollectionSuffix: true });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants