MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / create_policy

Method create_policy

nodedb/src/control/security/rls/store.rs:46–57  ·  view source on GitHub ↗

Create or replace an RLS policy.

(&self, policy: RlsPolicy)

Source from the content-addressed store, hash-verified

44
45 /// Create or replace an RLS policy.
46 pub fn create_policy(&self, policy: RlsPolicy) -> crate::Result<()> {
47 let key = policy_key(policy.tenant_id, &policy.collection);
48 let mut policies = self.lock_write();
49 let list = policies.entry(key).or_default();
50
51 if let Some(existing) = list.iter_mut().find(|p| p.name == policy.name) {
52 *existing = policy;
53 } else {
54 list.push(policy);
55 }
56 Ok(())
57 }
58
59 /// Drop an RLS policy. Returns `true` if a policy was removed.
60 pub fn drop_policy(&self, tenant_id: u64, collection: &str, policy_name: &str) -> bool {

Calls 6

policy_keyFunction · 0.85
lock_writeMethod · 0.80
entryMethod · 0.80
iter_mutMethod · 0.80
findMethod · 0.45
pushMethod · 0.45