2021年3月5日星期五

Firebase delete data with orderByChild() with a key?

When removing an item from my RTDB, my intention is to clean up user's likes if the item they like got removed.

With my data structure like so:

enter image description here

I am attempting to remove the nodes like this:

  firebase      .database()      .ref('userLikedStrains')      .orderByChild(title)      .equalTo(title)      .once('value', snapshot => {        console.log(snapshot.val())        snapshot.forEach(child => {          console.log(child.key)          updates[`/userLikedStrains/${child.key}/${title}`] = null;        });      })  

For some reason this doesn't work. Is it because I am targeting a key (which is still a child?..)

I appreciate any help with this! Cheers.

https://stackoverflow.com/questions/66501404/firebase-delete-data-with-orderbychild-with-a-key March 06, 2021 at 09:07AM

没有评论:

发表评论