update_row_policy()
Replaces a named row-level security policy while preserving its server-side identity.
pub async fn update_row_policy(&self, request: UpdateRowPolicyRequest) -> Result<()>
The policy must exist. All definition fields replace their previous values; omitted expressions and descriptions become empty strings. The caller must hold the ManageRLS privilege on the collection.
Request Syntax
let request = UpdateRowPolicyRequest::builder()
.collection_name("books")
.policy_name("team_policy")
.policy_type(RowPolicyType::Restrictive)
.actions([RowPolicyAction::Query])
.using_expr("team == $current_principal_tags['team']")
.build()?;
REQUEST FIELDS:
database_name: Option<String>Name of the target database; uses the default database when empty.
collection_name: StringName of the collection protected by the policy. Required.
policy_name: StringName of the policy to replace. Required.
policy_type: RowPolicyTypeRequired replacement policy-combination mode; it must be
PermissiveorRestrictive. See RowPolicyType.actions: Vec<RowPolicyAction>Replacement operations governed by the policy. Must contain at least one unique action. See RowPolicyAction.
using_expr: StringReplacement expression that filters rows for read and delete actions. At least one of
using_exprandcheck_expris required.check_expr: StringReplacement expression that validates rows for insert and upsert actions. At least one of
using_exprandcheck_expris required.description: StringReplacement description.
RETURN TYPE:
Result<()>
RETURNS:
Returns Ok(()) on success; returns an Error on failure.
Example
let request = UpdateRowPolicyRequest::builder()
.collection_name("books")
.policy_name("team_policy")
.policy_type(RowPolicyType::Restrictive)
.actions([RowPolicyAction::Query])
.using_expr("team == $current_principal_tags['team']")
.build()?;
client.update_row_policy(request).await?;