accessProvider.exists()

Learn: Access providers

Test if an access provider exists.

Signature

exists() => Boolean

Description

Tests if an access provider, represented as an AccessProvider document, exists.

AccessProvider documents are FQL versions of a database’s FSL access provider schema. AccessProvider documents have the AccessProvider type. See Access providers.

Staged schema

If a database has staged schema, this method interacts with the database’s staged schema, not the active schema.

exists() vs. null comparisons

You can use either exists() or a null comparison (== null or != null) to check the existence or validity of a value. For example:

AccessProvider.byName("someIssuer").exists()  // true

AccessProvider.byName("someIssuer") != null   // true

Key differences:

  • exists() returns an error if called on an unsupported value.

  • Null comparisons do not throw errors and work safely on any value.

For example:

// Declare an object. Objects don't support
// an `exists()` method.
let object = { a: "Foo", b: "Bar" }

object.exists()  // Returns `invalid_query` error

object != null   // Returns true

Parameters

None

Return value

Type Description

Boolean

If true, the AccessProvider document exists. If false, the AccessProvider document doesn’t exist.

Examples

AccessProvider.byName("someIssuer").exists()
true
\