You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I encountered strange behavior (at least in my opinion). I have a collection for which I have a saveItem method defined in meteorMethods. It is simple:
saveItem() {
var user = Meteor.user();
// CHECK IF USER IS SIGN IN
if (!user) throw new Meteor.Error(400, 'You must be logged in');
if (this._isNew) {
console.log("Saving item");
this.userId = user._id;
}
else {
console.log("Updating item");
if (this.userId != Meteor.userId()) {
throw new Meteor.Error(403, 'You are not authorized to edit this item');
}
}
// Save item
console.log(this.getModified());
return this.save({cast: true});
}
On the server I have a code:
let item = Item.findOne();
item.set('Name', "Updated Name");
console.log(item.getModified());
item.saveItem();
The set method is working well and first logging of item.getModified() shows ['Name']. However, in saveItem meteor method this.getModified() shows empty list and (obviously) the item is not updated in the database. Nonetheless, if I save the item on the server directly after set:
let item = Item.findOne();
item.set('Name', "Updated Name");
console.log(item.getModified());
item.save();
It is updated correctly. I am not sure if this behavior is inentional. Maybe I am doing something wrong here.
My version of Meteor is 1.5 and Astronomy is 2.4.6. Thanks for help.
The text was updated successfully, but these errors were encountered:
Yes, it's a bug. I'm working on fixing it. I've already fixed it but I have to make sure that it didn't break anything. I will probably publish new version later today.
Hi,
I encountered strange behavior (at least in my opinion). I have a collection for which I have a saveItem method defined in meteorMethods. It is simple:
On the server I have a code:
The
set
method is working well and first logging ofitem.getModified()
shows['Name']
. However, insaveItem
meteor methodthis.getModified()
shows empty list and (obviously) the item is not updated in the database. Nonetheless, if I save the item on the server directly afterset
:It is updated correctly. I am not sure if this behavior is inentional. Maybe I am doing something wrong here.
My version of Meteor is 1.5 and Astronomy is 2.4.6. Thanks for help.
The text was updated successfully, but these errors were encountered: