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寻求帮助! –
就是这样!再次诅咒你!祝你有美好的一天:) –