Access a Value¶
Overview¶
You can reference a Realm Value from a JSON expression or a Realm Function.
Usage¶
Reference a Value in a JSON Expression¶
You can access a Value's stored data from a JSON expression
using the %%values
expansion.
"%%values.<Value Name>"
Example
The following JSON expression evaluates to true
when the active
user's id is included in the plain text array Value
adminUsers
:
{ "%%user.id": { "%in": "%%values.adminUsers" } }
Reference a Value in a Function¶
You can access a Value's stored data from a Function using the context.values module.
context.values.get("<Value Name>")
Example
The following Function returns true
when the active
user's id is included in the plain text array Value
adminUsers
:
exports = function() { const adminUsers = context.values.get("adminUsers"); const isAdminUser = adminUsers.indexOf(context.user.id) > 0; return isAdminUser; }
Summary¶
- You can access a Realm Value from a JSON expression or from a Realm Function.
Give Feedback