Skip to content

Commit 993b9b4

Browse files
author
Jacob Wenger
authored
Updated description for ref() method to match reference docs (#135)
1 parent e5f0be0 commit 993b9b4

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

src/providers/database.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,27 @@ export const provider = 'google.firebase.database';
3434
const databaseURLRegex = new RegExp('https://([^.]+).firebaseio.com');
3535

3636
/**
37-
* Handle events at a Firebase Realtime Database ref.
37+
* Handle events at a Firebase Realtime Database Reference.
3838
*
39-
* The database.ref() functions behave very similarly to the normal Firebase
40-
* SDKs. Any change to the database that affects the data at or below ref will
41-
* fire an event in Cloud Functions.
39+
* This method behaves very similarly to the method of the same name in the
40+
* client and Admin Firebase SDKs. Any change to the Database that affects the
41+
* data at or below the provided `path` will fire an event in Cloud Functions.
4242
*
43-
* There are three important differences between listening to a database event
44-
* in Cloud Functions and using the Realtime Database SDK:
45-
* 1. The Cloud Functions SDK allows wildcards in the ref name. Any path
46-
* component in curly brackets ({}) will match any value. The actual value
47-
* that matched will be returned in eventnt.params. E.g. ref('foo/{bar}') will
48-
* match a change at 'foo/baz' and the event will have params {bar: 'baz'}.
49-
* 2. Unlike the Realtime Database SDK, Cloud Functions will not fire an event
50-
* for data that already existed before the Cloud Function was deployed.
51-
* 3. Cloud Function events have access to more information than the normal
52-
* SDK. E.g. the snapshot passed to a Cloud Function has access to the
53-
* previous event data as well as the user who triggered the change.
43+
* There are three important differences between listening to a Realtime
44+
* Database event in Cloud Functions and using the Realtime Database in the
45+
* client and Admin SDKs:
46+
* 1. Cloud Functions allows wildcards in the `path` name. Any `path` component
47+
* in curly brackets (`{}`) is a wildcard that matches all strings. The value
48+
* that matched a certain invocation of a Cloud Function is returned as part
49+
* of the `event.params` object. For example, `ref("messages/{messageId}")`
50+
* matches changes at `/messages/message1` or `/messages/message2`, resulting
51+
* in `event.params.messageId` being set to `"message1"` or `"message2"`,
52+
* respectively.
53+
* 2. Cloud Functions do not fire an event for data that already existed before
54+
* the Cloud Function was deployed.
55+
* 3. Cloud Function events have access to more information, including a
56+
* snapshot of the previous event data and information about the user who
57+
* triggered the Cloud Function.
5458
*/
5559
export function ref(path: string): RefBuilder {
5660
const normalized = normalizePath(path);

0 commit comments

Comments
 (0)