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

Exception when update document with set() #411

Closed
mytc opened this issue Jun 4, 2016 · 4 comments
Closed

Exception when update document with set() #411

mytc opened this issue Jun 4, 2016 · 4 comments

Comments

@mytc
Copy link

mytc commented Jun 4, 2016

This is my method to update a document:
actions.js

UpdateSpot(data, status){

            let input = {status : Number(status), ModifyOn: new Date()};
            let spot =  Spot.findOne(data._id);
            spot.set(input);

              spot.save(function(err,id){
                    if(err){
                        console.log(err);
                        throw new Meteor.Error('erro-obj', err);
                    }else{
                        return id;
                    }
              });


    }

But when I run this method, I get this exception:
Exception while invoking method 'UpdateSpot' { stack: 'TypeError: Cannot read property \'upsert\' of undefined\n at MongoConnection.mongoConnectionProto.(anonymous function) [as update] (packages/meteorhacks_kadira/lib/hijack/db.js:73:1)\n at OptimizedApply (packages/meteorhacks_kadira/lib/utils.js:31:1)\n at Object.ret.(anonymous function) [as update] (packages/meteorhacks_kadira/lib/hijack/db.js:20:1)\n at documentUpdate (packages/jagi:astronomy/lib/modules/storage/utils/document_update.js:75:41)\n at Class.save (packages/jagi:astronomy/lib/modules/storage/class_prototype_methods/save.js:106:50)\n at [object Object].UpdateSpot (apps/booking/server/actions.js:129:11)\n at [object Object].methodMap.(anonymous function) (packages/meteorhacks_kadira/lib/hijack/wrap_session.js:164:1)\n at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1704:12)\n at packages/ddp-server/livedata_server.js:711:19\n at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)',

However, the document properly updated though.

This only happens when updating document with set() method. For creating new document, it is working without any error.

I am using version 3.

@lukejagodzinski
Copy link
Member

It's probably not something related with Astronomy but you have to create reproduction because it's hard to tell. Version 3 of what? There is no version 3 of Astronomy.

@mytc
Copy link
Author

mytc commented Jun 4, 2016

My bad, it's version 2.
I was having this problem in other collections as well.
Also I am using Kadira ssr, maybe that is the problem.

@lukejagodzinski
Copy link
Member

Just create reproduction repository with only Astronomy added to the project. If problem persists that means the problem is on Astronomy side.

@philohelp
Copy link

philohelp commented Aug 21, 2016

I've got the same issue using save() for updating inside a meteor.method. Probably related to kadira:debug, as it went away when I removed the package. Maybe close to meteorhacks/kadira#12 and meteorhacks/kadira#83 if not kadirahq/meteor-debug#11.

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

No branches or pull requests

3 participants