How to set user context to execute database function as specific user on server side

Hi how do you set the user context to execute a database call as a specific user as my current rules are preventing the documents i’m querying for from being return?

I’m using realm sdk in cloudflare worker runtime environment using API key authenication.

the rule i have for the collection is a simple owner role rule : { “userId”: “”}

when i try to do a db.collection('todos').find({userId:'123')} the result is empty.

Solved my issue by adding another rule that allowed reading the collection for the given API key. Took solution from Define rule with API Key