Skip to content Skip to sidebar Skip to footer

Meteor Wont Update Data In Mongodb

I have this code: Nodes = new Meteor.Collection('nodes'); [...] Template.list.events({ 'click .toggle': function () { Session.set('selected_machine', this._id); Nodes

Solution 1:

This is because your data uses the MongoDB ObjectId, it's a known issue that Meteor can't update these values (https://github.com/meteor/meteor/issues/61).

you could run this hack in the mongo shell (meteor mongo) to fix it (credit to antoviaque, i just edited it for your collection)

db.nodes.find({}).forEach(function(el){
    db.nodes.remove({_id:el._id}); 
    el._id = el._id.toString(); 
    db.nodes.insert(el); 
});

Meteor sees the ObjectId just as a string and because of that MongoDB doesn't find something to update. It works client-side, because in your local collection these _id's are converted to strings.

For experimenting you should insert data via the browser console and not via the mongo shell, because then Meteor generates UUID's for you and everything is (and will be) fine.

PS: I ran into the same problem when I started on my App.

Post a Comment for "Meteor Wont Update Data In Mongodb"