Meteor.js: Collection.insert works on server but not client -


trying understand crud in meteor & have fundamental problem, when remove auto publish , use explicit pub/sub, collection inserts client update server not client collection.

the result while field values obtained properly, insert fails on client side. on server side, record inserted correctly.

$ meteor remove autopublish

create html form file (it's valid , functions expected), then:

file /server/publish.js:

meteor.publish('todos'), function() {     return todos.find(); } 

file /lib/collections.js:

todos = new mongo.collection('todos'); 

file /client/subscribe.js:

meteor.subscribe('todos'); 

file /client/todos.js:

template.todoslist.helpers({     todoslist: function() {         return todos.find();     },   });  template.todonew.events({     'submit form': function(event) {         event.preventdefault();         var therecord = {             description: $(event.target).find('[id=description]').val(),             priority: $(event.target).find('[id=priority]').val()         };         // display correct field values, form data ok         console.log('attemping insert: ' + therecord.description);         todos.insert(therecord, function(error) {             // error occurs             console.log('error inserting: ' + therecord.description);         });     } }); 

in order write collection client need allow rule. put under /server:

meteor.publish('todos', function() {   return todos.find(); });  todos.allow({   insert: function(userid, doc) {     // todo must have description , priority     return (doc.description && doc.priority);   } }); 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -