Namespace: firestore

Interfaces

Properties

request

static

non-null rules.firestore.Request

The request context, including authentication information and pending data.

resource

static

non-null rules.firestore.Resource

The resource being read or written.

Methods

exists

static

exists(path) returns rules.Boolean

Check if a document exists.

Parameter

path

rules.Path

The path.

Value must not be null.

Returns

non-null rules.Boolean true if the resource exists.

Example

// Check if another document exists
allow write: if exists(/databases/$(database)/documents/things/other)

existsAfter

static

existsAfter(path) returns rules.Boolean

Check if a document exists, assuming the current request succeeds. Equivalent to getAfter(path) != null.

Parameter

path

rules.Path

The path.

Value must not be null.

Returns

non-null rules.Boolean true if the resource exists.

get

static

get(path) returns rules.firestore.Resource

Get the contents of a firestore document.

Parameter

path

rules.Path

The path.

Value must not be null.

Returns

non-null rules.firestore.Resource the document, or null if it does not exist.

Example

// Get the 'thing1' document from the 'things' collection
get(/databases/$(database)/documents/things/thing1)

getAfter

static

getAfter(path) returns rules.firestore.Resource

Get the projected contents of a document. The document is returned as if the current request had succeeded. Useful for validating documents that are part of a batched write or transaction.

Parameter

path

rules.Path

The path.

Value must not be null.

Returns

non-null rules.firestore.Resource the document, or null if it does not exist.