maskah
February 27, 2017, 2:10am
1
Hello,
I’m new to Meteor and i met my first issue.
I’m using autoform and i need to update a collection from server. It works well with autoform.
//schema
Schemas.Enregistrement = new SimpleSchema({
//...
type: {
type: String,
autoform: {
type: 'hidden'
},
autoValue:function(){ return 'devis' }
},
//...
});
//server
Enregistrements.update(enregistrementId, { $set: { type: 'facture' } });
//allow
Enregistrements.allow({
//...
update: function (userId, doc) {
return (userId && doc.user === userId);
},
//...
});
Enregistrements.update callback doesent return any error and number = 1 as expected.
In Enregistrements.allow update, (userId && doc.user === userId) is returning true as expected too
But my collection is not updated
Any idea ? Thanks
Your autovalue is overwriting your submitted value on every update.
brucejo
February 27, 2017, 5:21am
3
What is enregistrementId
? Maybe you are not setting your Collection selector correctly?
You might also want to look at the mongo docs for find . This shows how to use a selector.
In your case, think you may want {_id: enregistrementId}
as your selector.
brucejo
February 27, 2017, 5:23am
4
that is a good point too.
maskah
February 27, 2017, 7:51pm
5
It was my first thought but no success
maskah
February 27, 2017, 7:55pm
6
I’m using Collection2 and it seems i can use an id as selector. but {_id: enregistrementId} doesent work too
Thanks for your answers.
I set up an alternative with autoform & jquery.
I will look for the bug later
Try like this instead…
//schema
Schemas.Enregistrement = new SimpleSchema({
//...
type: {
type: String,
autoform: {
type: 'hidden'
},
autoValue:function(){
if(!this.isSet) {
return 'devis';
}
}
},
//...
});
maskah
February 27, 2017, 8:52pm
8
Doesn’t work
I will look for a solution in few days. Jquery makes the stuff for now.
Thank you