-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Description
I have faced with strange behaviour of 'save' method.
I have a class Unit that is extended on server side
Unit.extend({
meteorMethods: {
insert() {
this.name = 'insert name';
const id = this.save();
const parentUnit = Unit.findOne({_id: this.parentUnitId});
console.log('parentUnit', parentUnit);
parentUnit.changeName();
},
},
methods: {
changeName(){
console.log('change name is called');
this.name = 'changed name';
console.log(this);
this.save()
}
}
});
When I call method 'insert' from client side like this:
const unit = new Unit({
name: 'New Unit Name',
parentUnitId: this.selectedUnitHolder.get()._id,
});
unit.callMethod('insert');
I get properly stored new unit in db, but parent unit is not updated although console output from changeName method look as
Class {
_isNew: false,
_id: 'jiM8ZXBuayz6H4Za5',
name: 'changed name',
parentUnitId: undefined}
The field 'name' of parent unit has non-changed value in db.
But! the saving in method work as expected if I call it for the original object like this
Unit.extend({
meteorMethods: {
insert() {
this.name = 'insert name';
const id = this.save();
//const parentUnit = Unit.findOne({_id: this.parentUnitId});
//console.log('parentUnit', parentUnit);
this.changeName();
},
},
methods: {
changeName(){
console.log('change name is called');
this.name = 'changed name';
console.log(this);
this.save()
}
}
});
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels