## Functions

| Function | Description |
|---|---|
| [onValueCreated(reference, handler)](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database#databaseonvaluecreated) | Event handler which triggers when data is created in Realtime Database. |
| [onValueCreated(reference, handler)](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database#databaseonvaluecreated) | Event handler which triggers when data is created in Realtime Database. |
| [onValueCreated(opts, handler)](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database#databaseonvaluecreated) | Event handler which triggers when data is created in Realtime Database. |
| [onValueCreated(opts, handler)](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database#databaseonvaluecreated) | Event handler which triggers when data is created in Realtime Database. |
| [onValueDeleted(reference, handler)](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database#databaseonvaluedeleted) | Event handler which triggers when data is deleted in Realtime Database. |
| [onValueDeleted(reference, handler)](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database#databaseonvaluedeleted) | Event handler which triggers when data is deleted in Realtime Database. |
| [onValueDeleted(opts, handler)](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database#databaseonvaluedeleted) | Event handler which triggers when data is deleted in Realtime Database. |
| [onValueDeleted(opts, handler)](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database#databaseonvaluedeleted) | Event handler which triggers when data is deleted in Realtime Database. |
| [onValueUpdated(reference, handler)](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database#databaseonvalueupdated) | Event handler which triggers when data is updated in Realtime Database. |
| [onValueUpdated(reference, handler)](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database#databaseonvalueupdated) | Event handler which triggers when data is updated in Realtime Database. |
| [onValueUpdated(opts, handler)](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database#databaseonvalueupdated) | Event handler which triggers when data is updated in Realtime Database. |
| [onValueUpdated(opts, handler)](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database#databaseonvalueupdated) | Event handler which triggers when data is updated in Realtime Database. |
| [onValueWritten(reference, handler)](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database#databaseonvaluewritten) | Event handler which triggers when data is created, updated, or deleted in Realtime Database. |
| [onValueWritten(reference, handler)](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database#databaseonvaluewritten) | Event handler which triggers when data is created, updated, or deleted in Realtime Database. |
| [onValueWritten(opts, handler)](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database#databaseonvaluewritten) | Event handler which triggers when data is created, updated, or deleted in Realtime Database. |
| [onValueWritten(opts, handler)](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database#databaseonvaluewritten) | Event handler which triggers when data is created, updated, or deleted in Realtime Database. |

## Classes

| Class | Description |
|---|---|
| [DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class) | Interface representing a Firebase Realtime database data snapshot. |

## Interfaces

| Interface | Description |
|---|---|
| [DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface) | A CloudEvent that contains a DataSnapshot or a Change |
| [RawRTDBCloudEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.rawrtdbcloudevent#databaserawrtdbcloudevent_interface) |   |
| [RawRTDBCloudEventData](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.rawrtdbcloudeventdata#databaserawrtdbcloudeventdata_interface) |   |
| [ReferenceOptions](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.referenceoptions#databasereferenceoptions_interface) | ReferenceOptions extend EventHandlerOptions with provided ref and optional instance |

## Type Aliases

| Type Alias | Description |
|---|---|
| [AuthType](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database#databaseauthtype) | AuthType defines the possible values for the authType field in a Realtime Database event. - app_user: an end user of an application.. - admin: an admin user of an application. In the context of impersonate endpoints used by the admin SDK, the impersonator. - unauthenticated: no credentials were used to authenticate the change that triggered the occurrence. - unknown: a general type to capture all other principals not captured in the other auth types. |

## database.onValueCreated()

Event handler which triggers when data is created in Realtime Database.

**Signature:**

    export declare function onValueCreated<Ref extends string>(reference: Ref, handler: (event: DatabaseEvent<DataSnapshot, ParamsOf<Ref>> & V1Compat<"snapshot", DataSnapshot>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot, ParamsOf<Ref>>>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| reference | Ref | The database reference path to trigger on. |
| handler | (event: [DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class), [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\> \& V1Compat\<"snapshot", [DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>) =\> any \| Promise\<any\> | Event handler which is run every time a Realtime Database create occurs. |

**Returns:**

[CloudFunction](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.cloudfunction#cloudfunction_interface)\<[DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class), [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>\>

## database.onValueCreated()

Event handler which triggers when data is created in Realtime Database.

**Signature:**

    export declare function onValueCreated<Ref extends string>(reference: Ref, handler: (event: DatabaseEvent<DataSnapshot, ParamsOf<Ref>>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot, ParamsOf<Ref>>>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| reference | Ref | The database reference path to trigger on. |
| handler | (event: [DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class), [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>) =\> any \| Promise\<any\> | Event handler which is run every time a Realtime Database create occurs. |

**Returns:**

[CloudFunction](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.cloudfunction#cloudfunction_interface)\<[DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class), [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>\>

## database.onValueCreated()

Event handler which triggers when data is created in Realtime Database.

**Signature:**

    export declare function onValueCreated<Ref extends string>(opts: ReferenceOptions<Ref>, handler: (event: DatabaseEvent<DataSnapshot, ParamsOf<Ref>> & V1Compat<"snapshot", DataSnapshot>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot, ParamsOf<Ref>>>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| opts | [ReferenceOptions](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.referenceoptions#databasereferenceoptions_interface)\<Ref\> | Options that can be set on an individual event-handling function. |
| handler | (event: [DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class), [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\> \& V1Compat\<"snapshot", [DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>) =\> any \| Promise\<any\> | Event handler which is run every time a Realtime Database create occurs. |

**Returns:**

[CloudFunction](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.cloudfunction#cloudfunction_interface)\<[DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class), [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>\>

## database.onValueCreated()

Event handler which triggers when data is created in Realtime Database.

**Signature:**

    export declare function onValueCreated<Ref extends string>(opts: ReferenceOptions<Ref>, handler: (event: DatabaseEvent<DataSnapshot, ParamsOf<Ref>>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot, ParamsOf<Ref>>>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| opts | [ReferenceOptions](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.referenceoptions#databasereferenceoptions_interface)\<Ref\> | Options that can be set on an individual event-handling function. |
| handler | (event: [DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class), [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>) =\> any \| Promise\<any\> | Event handler which is run every time a Realtime Database create occurs. |

**Returns:**

[CloudFunction](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.cloudfunction#cloudfunction_interface)\<[DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class), [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>\>

## database.onValueDeleted()

Event handler which triggers when data is deleted in Realtime Database.

**Signature:**

    export declare function onValueDeleted<Ref extends string>(reference: Ref, handler: (event: DatabaseEvent<DataSnapshot, ParamsOf<Ref>> & V1Compat<"snapshot", DataSnapshot>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot, ParamsOf<Ref>>>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| reference | Ref | The database reference path to trigger on. |
| handler | (event: [DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class), [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\> \& V1Compat\<"snapshot", [DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>) =\> any \| Promise\<any\> | Event handler which is run every time a Realtime Database deletion occurs. |

**Returns:**

[CloudFunction](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.cloudfunction#cloudfunction_interface)\<[DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class), [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>\>

## database.onValueDeleted()

Event handler which triggers when data is deleted in Realtime Database.

**Signature:**

    export declare function onValueDeleted<Ref extends string>(reference: Ref, handler: (event: DatabaseEvent<DataSnapshot, ParamsOf<Ref>>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot, ParamsOf<Ref>>>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| reference | Ref | The database reference path to trigger on. |
| handler | (event: [DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class), [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>) =\> any \| Promise\<any\> | Event handler which is run every time a Realtime Database deletion occurs. |

**Returns:**

[CloudFunction](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.cloudfunction#cloudfunction_interface)\<[DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class), [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>\>

## database.onValueDeleted()

Event handler which triggers when data is deleted in Realtime Database.

**Signature:**

    export declare function onValueDeleted<Ref extends string>(opts: ReferenceOptions<Ref>, handler: (event: DatabaseEvent<DataSnapshot, ParamsOf<Ref>> & V1Compat<"snapshot", DataSnapshot>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot, ParamsOf<Ref>>>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| opts | [ReferenceOptions](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.referenceoptions#databasereferenceoptions_interface)\<Ref\> | Options that can be set on an individual event-handling function. |
| handler | (event: [DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class), [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\> \& V1Compat\<"snapshot", [DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>) =\> any \| Promise\<any\> | Event handler which is run every time a Realtime Database deletion occurs. |

**Returns:**

[CloudFunction](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.cloudfunction#cloudfunction_interface)\<[DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class), [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>\>

## database.onValueDeleted()

Event handler which triggers when data is deleted in Realtime Database.

**Signature:**

    export declare function onValueDeleted<Ref extends string>(opts: ReferenceOptions<Ref>, handler: (event: DatabaseEvent<DataSnapshot, ParamsOf<Ref>>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot, ParamsOf<Ref>>>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| opts | [ReferenceOptions](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.referenceoptions#databasereferenceoptions_interface)\<Ref\> | Options that can be set on an individual event-handling function. |
| handler | (event: [DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class), [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>) =\> any \| Promise\<any\> | Event handler which is run every time a Realtime Database deletion occurs. |

**Returns:**

[CloudFunction](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.cloudfunction#cloudfunction_interface)\<[DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class), [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>\>

## database.onValueUpdated()

Event handler which triggers when data is updated in Realtime Database.

**Signature:**

    export declare function onValueUpdated<Ref extends string>(reference: Ref, handler: (event: DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>> & V1Compat<"change", Change<DataSnapshot>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| reference | Ref | The database reference path to trigger on. |
| handler | (event: [DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>, [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\> \& V1Compat\<"change", [Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>\>) =\> any \| Promise\<any\> | Event handler which is run every time a Realtime Database update occurs. |

**Returns:**

[CloudFunction](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.cloudfunction#cloudfunction_interface)\<[DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>, [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>\>

## database.onValueUpdated()

Event handler which triggers when data is updated in Realtime Database.

**Signature:**

    export declare function onValueUpdated<Ref extends string>(reference: Ref, handler: (event: DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| reference | Ref | The database reference path to trigger on. |
| handler | (event: [DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>, [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>) =\> any \| Promise\<any\> | Event handler which is run every time a Realtime Database update occurs. |

**Returns:**

[CloudFunction](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.cloudfunction#cloudfunction_interface)\<[DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>, [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>\>

## database.onValueUpdated()

Event handler which triggers when data is updated in Realtime Database.

**Signature:**

    export declare function onValueUpdated<Ref extends string>(opts: ReferenceOptions<Ref>, handler: (event: DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>> & V1Compat<"change", Change<DataSnapshot>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| opts | [ReferenceOptions](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.referenceoptions#databasereferenceoptions_interface)\<Ref\> | Options that can be set on an individual event-handling function. |
| handler | (event: [DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>, [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\> \& V1Compat\<"change", [Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>\>) =\> any \| Promise\<any\> | Event handler which is run every time a Realtime Database update occurs. |

**Returns:**

[CloudFunction](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.cloudfunction#cloudfunction_interface)\<[DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>, [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>\>

## database.onValueUpdated()

Event handler which triggers when data is updated in Realtime Database.

**Signature:**

    export declare function onValueUpdated<Ref extends string>(opts: ReferenceOptions<Ref>, handler: (event: DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| opts | [ReferenceOptions](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.referenceoptions#databasereferenceoptions_interface)\<Ref\> | Options that can be set on an individual event-handling function. |
| handler | (event: [DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>, [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>) =\> any \| Promise\<any\> | Event handler which is run every time a Realtime Database update occurs. |

**Returns:**

[CloudFunction](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.cloudfunction#cloudfunction_interface)\<[DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>, [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>\>

## database.onValueWritten()

Event handler which triggers when data is created, updated, or deleted in Realtime Database.

**Signature:**

    export declare function onValueWritten<Ref extends string>(reference: Ref, handler: (event: DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>> & V1Compat<"change", Change<DataSnapshot>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| reference | Ref | The database reference path to trigger on. |
| handler | (event: [DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>, [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\> \& V1Compat\<"change", [Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>\>) =\> any \| Promise\<any\> | Event handler which is run every time a Realtime Database create, update, or delete occurs. |

**Returns:**

[CloudFunction](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.cloudfunction#cloudfunction_interface)\<[DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>, [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>\>

## database.onValueWritten()

Event handler which triggers when data is created, updated, or deleted in Realtime Database.

**Signature:**

    export declare function onValueWritten<Ref extends string>(reference: Ref, handler: (event: DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| reference | Ref | The database reference path to trigger on. |
| handler | (event: [DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>, [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>) =\> any \| Promise\<any\> | Event handler which is run every time a Realtime Database create, update, or delete occurs. |

**Returns:**

[CloudFunction](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.cloudfunction#cloudfunction_interface)\<[DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>, [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>\>

## database.onValueWritten()

Event handler which triggers when data is created, updated, or deleted in Realtime Database.

**Signature:**

    export declare function onValueWritten<Ref extends string>(opts: ReferenceOptions<Ref>, handler: (event: DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>> & V1Compat<"change", Change<DataSnapshot>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| opts | [ReferenceOptions](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.referenceoptions#databasereferenceoptions_interface)\<Ref\> | Options that can be set on an individual event-handling function. |
| handler | (event: [DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>, [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\> \& V1Compat\<"change", [Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>\>) =\> any \| Promise\<any\> | Event handler which is run every time a Realtime Database create, update, or delete occurs. |

**Returns:**

[CloudFunction](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.cloudfunction#cloudfunction_interface)\<[DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>, [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>\>

## database.onValueWritten()

Event handler which triggers when data is created, updated, or deleted in Realtime Database.

**Signature:**

    export declare function onValueWritten<Ref extends string>(opts: ReferenceOptions<Ref>, handler: (event: DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| opts | [ReferenceOptions](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.referenceoptions#databasereferenceoptions_interface)\<Ref\> | Options that can be set on an individual event-handling function. |
| handler | (event: [DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>, [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>) =\> any \| Promise\<any\> | Event handler which is run every time a Realtime Database create, update, or delete occurs. |

**Returns:**

[CloudFunction](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.cloudfunction#cloudfunction_interface)\<[DatabaseEvent](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.databaseevent#databasedatabaseevent_interface)\<[Change](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.change#change_class)\<[DataSnapshot](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.database.datasnapshot#databasedatasnapshot_class)\>, [ParamsOf](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions#paramsof)\<Ref\>\>\>

## database.AuthType

AuthType defines the possible values for the authType field in a Realtime Database event. - app_user: an end user of an application.. - admin: an admin user of an application. In the context of impersonate endpoints used by the admin SDK, the impersonator. - unauthenticated: no credentials were used to authenticate the change that triggered the occurrence. - unknown: a general type to capture all other principals not captured in the other auth types.

**Signature:**

    export type AuthType = "app_user" | "admin" | "unauthenticated" | "unknown";