首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从Firebase中删除特定用户

从Firebase中删除特定用户
EN

Stack Overflow用户
提问于 2016-07-08 14:53:44
回答 0查看 1.1K关注 0票数 0

我试着做一个在线数据库(Firebase),用于测试和学习。我成功地在数据库中添加了成员,但我不知道我的remove代码的问题在哪里。

下面是我的代码:

代码语言:javascript
复制
<!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);
      });
      }
      var ref = new Firebase("https://projecttest-9aee9.firebaseio.com/web/saving-data/fireblog/users");
      var usersRef= ref.child("users");
      function remove(){
          usersRef.remove({

          .then(function() {
             console.log("Remove succeeded.")
                            })
          .catch(function(error) {
             console.log("Remove failed: " + error.message)
                                 })
        });
        }
      </script>
    </body>
</html>

我是新手,我需要你的帮助!

感谢您的关注!

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38260596

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档