0
我開始詳細瞭解Firebase,並嘗試創建簡單的數據庫。從Firebase數據庫中刪除用戶
我遵循從網站的所有步驟,我成功地在數據庫中添加成員。
但是...現在,有必要了解如何刪除用戶。
這裏是我的代碼,添加和刪除用戶:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<button onclick="saveData()">Save Data</button>
<button onclick="printData()">Print Data</button>
<button onclick="printData2()">Print Data2</button>
<button onclick="remove()">Remove</button>
<script src="https://cdn.firebase.com/js/client/2.4.2/firebase.js"></script>
<script>
var ref = new Firebase("https://projecttest-9aee9.firebaseio.com/web/saving-data/fireblog");
var usersRef = ref.child("users");
function saveData(){
usersRef.set({
alanisawesome: {
date_of_birth: "June 23, 1912",
full_name: "Alan Turing"
},
gracehop: {
date_of_birth: "December 9, 1906",
full_name: "Grace Hopper"
}
});
}
function printData(){
usersRef.on("value", function(snapshot) {
console.log(snapshot.val());
}, function (errorObject) {
console.log("The read failed: " + errorObject.code);
});
}
function printData2(){
ref.child("users/gracehop/date_of_birth").on("value", function(snapshot) {
console.log(snapshot.val());//"December 9, 1906"
}, function (errorObject) {
console.log("The read failed: " + errorObject.code);
});
}
function remove(){
ref.removeUser({
alanisawesome: {
date_of_birth: "June 23, 1912",
full_name: "Grace Hopper"
}
});
}
</script>
</body>
</html>
如果是刪除用戶功能的問題?
謝謝你的幫忙!
VAR REF =新的火力地堡(「https://projecttest-9aee9.firebaseio.com /網絡/保存數據/ fireblog「); ref.remove({alanisawesome:{ date_of_birth:「1912年6月23日」, 全名:「Alan Turing」 } }); –
也許......類似的東西? Thaanks尋求幫助! –
就是這樣!再次詛咒你!祝你有美好的一天:) –