javascript - Firebase remove node based on child value -


i want delete entire node query delete * user_id = "-ktrupwryo9wfj-tf8ft" how can achieve on firebase?

-kvpqfxnzqkzzrowhxgk   answer: "1"   question_number: 2   user_id: "-ktrupwryo9wfj-tf8ft" -kvpqfxodhsamjyfnjy7   answer: "4"   question_number: 25   user_id: "-ktrupwryo9wfj-tf8ft" 

to delete references child having particular value first need retrieve keys ('-kvpqfxnzqkzzrowhxgk', '-kvpqfxnzqkzzrowhxgk' in case) equalto query , delete references remove function.

a sample code here.

var ref = firebase.database(); //root reference data ref.orderbychild('user_id').equalto('-ktrupwryo9wfj-tf8ft')     .once('value').then(function(snapshot) {         snapshot.foreach(function(childsnapshot) {         //remove each child         ref.child(childsnapshot.key).remove();     }); }); 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -