[SERVER-25685] Extend update command to perform per-operation validation Created: 18/Aug/16  Updated: 06/Dec/22  Resolved: 29/Jun/19

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Michael O'Brien Assignee: Backlog - Query Team (Inactive)
Resolution: Won't Do Votes: 0
Labels: transactions
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query
Participants:

 Description   

Currently all validation settings exist in collection options, so they apply to all updates and inserts collection-wide.
It would be useful to have the ability to specify a validation condition per-op, so that rules that have parameters based on the context of the op can be used as part of the validation rule.

There is no way to do this client side, because the client can not know the result of applying the update modifiers.

example:

db.runCommand({"update",
  {updates:  [
    q: { user: "bobby.tables" }, 
    u: { $inc: {score:100} } , 
    upsert : false, 
    multi: true, 
    validator: { score: {$lt: team.score_limit } }
   ]}
});



 Comments   
Comment by Asya Kamsky [ 29/Jun/19 ]

SERVER-40381 implemented support for aggregation expressions to specify update for 4.2. 

You can see some examples here.

Aside from aggregation expression syntax being slightly different I think this allows what is described in this ticket. LMK if that's not the case (and re-open) please.

Generated at Thu Feb 08 04:09:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.