Docs Menu

Access a Value

You can access a Realm Value from a rule expression or a Realm Function.

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" } }

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;
}
Tip
See also: Reference an Environment Variable

Trying to access an environment variable? Check out the function context documentation for more info on context.environment.values().

←  Define Environment ValuesApplication Logs →
Give Feedback
© 2022 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2022 MongoDB, Inc.