Hi,
ValidatedMethod is using the returnStubValue option when calling a method, but it doesn’t seem to work for me. I would like to know what you think about it.
Here is my server side method:
export const updateName = new ValidatedMethod({
name: 'travelers.updateName',
validate: new SimpleSchema({
travelerId: { type: String, regEx: SimpleSchema.RegEx.Id },
newName: { type: String },
}).validator(),
run({ travelerId, newName }) {
if (this.isSimulation) {
return { finished: false };
}
Travelers.update(travelerId, { $set: { name: newName } });
return { finished: true };
},
});
This a simple method that updates a name property in my Travellers collection. Client side I immediately return an object { finished: false }
. Server side I update my database then return an object { finished: true }
Here is my client side call:
updateName.call({
travelerId: this.props.travelerId,
newName: value,
}, (err, res) => {
console.log(res);
});
I just call the method and console.log the result. Because I am using mdg:validated-method which uses the returnStubValue
option, I guess my console should output finished: false
, then finished: true
. But it actually only output finished: true
.
Is there something I don’t understand here?
Thank you and sorry if my english is not perfect.