So now, on the wire, the DDP method calls for update and remove take a single object id (though a selector of the form {_id: foo} is still accepted for now, for compatibility.)
--
You received this message because you are subscribed to the Google Groups "meteor-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to meteor-talk...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Ken, you may have misunderstood. You can still say `MyCollection.update(foo, ...)`, where `foo` is an _id string. It's just the selector syntax with the curly braces that's deprecated but supported for back-compat.
The fix was to remove the ability of untrusted clients to attempt updates or remove that could affect more than one document at once. This functionality was simply turning out to be more trouble than it was worth.
Virtually nobody used it, it is easily replaced with a method call (which if you're doing a complex operation is better style anyway)
Right now we have two solutions:
1) collection.find({...}).forEach
and issue updates by _id. This is obviously far less efficient than a single update with {multi: true}.
2. Define a Meteor.method to update the collection on the server with {multi: true}
. The problem is you'll have to pass a collection name as a parameter, and the server will have to look it up in the global namespace. This is what @mizzao's autocomplete does:
collection = global[collName]
...
collection.find(...)
So we're back at offering arbitrary access to server collections.
Worse, the recordset that's being modified on the client is a subset of the recordset on the server. Telling the server via Meteor.methods to update
based on a selector
may select more records than was intended on the client.
Also, the records on the client might have arrived from multiple collections. This makes it even more complicated to tell the server what to update.
Is there a good solution to this problem? It's important because currently Meteor doesn't have any good integrations with complex widgets such as grids or trees, and solving this would enable efficient modifications of multiple records at once.
Given the attack described in the original post, I believe an update where the selector is _id
and some-other-criterias should be authorized in untrusted environments. This is usefull along with mongoDB $
to edit a denormalized sub-document using the sub-document id. The query is as follow:
Posts.update({
_id: postId,
'comments._id': commentId
}, {
$set: {
'comments.$.message': newMessage
}
});
Am I right assuming that this query could be accepted in untrusted environments?
c.update({_id: 'some ID', 'some.secret.token': /^[a-m]/}, {$set: {'profile.matches': true}});
'some.secret.token': /^[a-m]/