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 =新Firebase(「https://projecttest-9aee9.firebaseio.com/web/saving-data/fireblog "); ref.remove({ alanisawesome:{ DATE_OF_BIRTH: "1912年6月23日"、 FULL_NAME: "アラン・チューリング" }})。 –
おそらく...そのようなもの?助けを求めるThaanks! –
それだけです!もう一度Thaank!素敵な一日を過ごしてください:) –