Query.isEnvProtected()

Test if the queried database is in protected mode.

Signature

Query.isEnvProtected() => Boolean

Description

Tests if the queried database is in protected mode, which prohibits destructive operations on a database’s collections.

The method checks the database to which the query’s authentication secret is scoped.

Parameters

None

Return value

Type Description

Boolean

If true, the database is in protected mode. Otherwise, false.

Examples

Call isEnvProtected() with built-in Admin role, on an unprotected database:

Query.isEnvProtected()
false

 

Calling isEnvProtected() with built-in Server role fails:

Query.isEnvProtected()
permission_denied: Insufficient privileges to perform the action.

error: Insufficient privileges to perform the action.
at *query*:1:21
  |
1 | Query.isEnvProtected()
  |                     ^^
  |
\