Skip to content

Commit

Permalink
chore(functions/firebase): fix RTDB paths not working (#2090)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ace Nassri authored Dec 3, 2020
1 parent 1aa77a1 commit 516e5ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions functions/firebase/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
* Triggered by a change to a Firebase RTDB reference.
*
* @param {!Object} event The Cloud Functions event.
* @param {!Object} context The Cloud Functions event context.
(Required to access RTDB path parameters.)
*/
exports.helloRTDB = event => {
exports.helloRTDB = (event, context) => {
const triggerResource = event.resource;

const pathParams = event.params;
const pathParams = context.params;
if (pathParams) {
console.log('Path parameters:');
Object.keys(pathParams).forEach(key => {
Expand Down
4 changes: 3 additions & 1 deletion functions/firebase/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ describe('functions_firebase_rtdb', () => {
admin: true,
},
delta: delta,
};
const context = {
params: {
baz: 'quux',
},
};

sample.program.helloRTDB(event);
sample.program.helloRTDB(event, context);

assert.strictEqual(console.log.calledWith(' baz: quux'), true);
assert.strictEqual(
Expand Down

0 comments on commit 516e5ea

Please sign in to comment.