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

collection.update inside Cursor.observe(changed) does not work #5709

Closed
mcwonka opened this issue Nov 25, 2015 · 2 comments
Closed

collection.update inside Cursor.observe(changed) does not work #5709

mcwonka opened this issue Nov 25, 2015 · 2 comments

Comments

@mcwonka
Copy link

mcwonka commented Nov 25, 2015

Hey folks,

we are facing an issue calling collection.update() inside a changed callback of Cursor.observer()

collection1 = new Mongo.Collection('collection1')
collection2 = new Mongo.Collection('collection2')

collection1.find().observe {

  added: (document) ->
    #is working
    console.log 'update 1', collection1.update({_id: newDocument._id}, {updateOnAdd: true}) 
    #is  working 
    console.log 'insert 1',  collection2.insert({insertOnAdd: true}) 


  changed: (newDocument, oldDocument) ->
    #is working
    console.log 'update 2', collection1.update({_id: newDocument._id}, {updateOnChange: true}) 
    # is _not_ working
    console.log 'insert 1',  collection2.insert({insertOnChange: true})  
}

Only the insert into collection2 on changed is not working although it returns 1 (affected rows). I think it has to do something with the simulation and that it is reset afterwards.It's strange to me that the insert works on added, but not on changed. Can you confirm this as a bug or is it intended that you can only update the observed collection on changed?

Thank you very much for your help!
Matthias

@zol
Copy link
Contributor

zol commented Dec 1, 2015

Hey @mcwonka

This should work. Please provide a full reproduction as described in: https://github.com/meteor/meteor/wiki/Contributing-to-Meteor#reporting-a-bug-in-meteor . Providing an easy to run reproduction will help us solve diagnose quickly.

@stubailo
Copy link
Contributor

stubailo commented Jan 5, 2016

Closing until a repro appears.

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

No branches or pull requests

3 participants