var getContent = "this is an example";
var theCase = Cases.findOne({ mobileNumber:getPhoneFrom, caseStatus:"open" });
Cases.update(theCase._id,
{$set: {
content: getContent,
messageStatus:'reply',
}
}
);
The Cases.update simply doesn’t run, the script dies out… but there are no errors reported in the log when running on Galaxy. If I put console.log(‘before’) and an console.log(‘after’) – the after does not run.
@vooteles no correct, this can be a string. Meteor will make a query out of it for you.
@SkyRooms have you checked that the doc exists? do you use a schema? do you use collection2? Maybe those fields are not in the schema, then collection2 would filter them out? wildly guessing here
Finally got some where, reading carefully through these docs:
Books.update(id, {$set: {“borrowedBy.1.name”: “Frank”}});
However, this will not pass validation. Why? Because we don’t know whether item 1 in the borrowedBy array already exists, so we don’t know whether it will have the required email property after the update finishes.
There are three ways to make this work:
$set the entire object
$set all required keys in the object
Perform the update on the server, and pass the validate: false option to skip validation.
When this situation occurs on the client with an autoForm, it generally does not cause any problems because AutoForm is smart enough to $set the entire object; it’s aware of this potential issue. However, this means that you need to ensure that all required properties are represented by an input on the form. In our example, if you want an autoForm that only shows a field for changing the borrowedBy name and not the email, you should include both fields but make the email field hidden. Alternatively, you can submit the autoForm to a server method and then do a server update without validation.
Although these examples focused on an array of objects, sub-objects are treated basically the same way.
So I stripped my schema right down to just caseStatus.
WORKS
Cases.update(theCase._id, {$set: {“caseStatus”: “closed”}});