Home:ALL Converter>How to delete parent key by its value in firebase using javascript

How to delete parent key by its value in firebase using javascript

Ask Time:2021-09-22T05:26:32         Author:newnick988888

Json Formatter

So I'm a newbie in using firebase real time database and I can't delete products key child with id specified.

enter image description here

I've tried this approach but it didn't yield any success:

removeProductById = async (id, user) => {
    const userProductRef = db.ref(`products/product`);
    try{
        var query = userProductRef.orderByChild('id').equalTo(id);
        query.remove()             
        })

    }catch(error){
        console.log(`The error has occured ${error.message}`)
    }
}

So I wanna know how can one delete any tipe of key by whatever value they specify. Thank you in advance, you have always helped me guys.

Author:newnick988888,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69275735/how-to-delete-parent-key-by-its-value-in-firebase-using-javascript
yy