Description
[REQUIRED] Environment info
firebase-tools: 9.23.3
Platform: macOS
[REQUIRED] Test case
exports.testDelete = functions.database
.instance("rdb-2")
.ref("/foo/bar1")
.onDelete(async (snapshot, context) => {
await snapshot.ref.set(0);
});
exports.testUpdate = functions.database
.instance("rdb-2")
.ref("/foo/bar1")
.onUpdate(async (change, context) => {
await change.before.ref.parent.child("bar3").set(789);
await change.after.ref.set(789);
});
exports.testCreate = functions.database
.instance("rdb-2")
.ref("/foo/bar1")
.onCreate(async (snapshot, context) => {
await snapshot.ref.parent.child("bar2").set(456);
});
[REQUIRED] Steps to reproduce
- copy-paste the code above and start the firebase emulators
- in the firebase emulator console, navigate to the rdb-2 realtime database instance
- add a node at
foo/bar1
giving it a value of let's say123
- change the value to let's say
456
- delete the node
[REQUIRED] Expected behavior
After step 3, I'd expect there a sibling bar2
to appear having the value 456
.
After step 4, I'd expect there a sibling bar3
to appear having the value 789
, and having the value itself change to 789
(which would then trigger the function once more).
After step 5, I'd expect the deleted node to reappear with the value 0
.
[REQUIRED] Actual behavior
After step 3, a node at foo/bar2
with the value 456
appears in the default database instance, instead of the rdb-2
instance.
After step 4, a node at foo/bar3
with the value 789
and a node at foo/bar1
with the value 789
appears in the default database instance, instead of the rdb-2
instance.
After step 5, the node foo/bar1
changes to a value 0
in the default database instance, instead of the rdb-2
instance.