firebase 資料庫 Realtime Database






透過FireBase  登入google帳號,建立一個專案選擇加入資料庫功能






在下圖中紅框新增應用程式中可以取得 script 代碼 取得後可以加入 html 檔中








並且引入
 <script src="https://www.gstatic.com/firebasejs/6.0.1/firebase-database.js"></script>
就可以透過  firebase.database().ref().set(' XXX') 寫入database
ref() :尋找資料庫路徑
set(): 寫入資料
###################################################
firebase 資料庫結構採物件結構
firebase.database().ref().set({
        student1:{
             name:'tom',
             num:'1'
                 },
        student2:{
            name:'john',
            num:'2'
                 }

       })
當執行以上程式碼,資料庫也會將此結構寫入




若要修改其中物件student1 名字可以 使用ref() 指向該位置

執行以下指令修改 student1 name
firebase.database().ref('student1/name').set('bob');











ref:https://firebase.google.com/?gclid=CjwKCAjwq4fsBRBnEiwANTahcKibsLvRQmpeKSdlBnI5xDoty0KfgHjik4pBJcX5c4dxOWQAy72dxxoCDv8QAvD_BwE

留言

熱門文章