zyuan8591 / aaron-vue-web

https://aaron-vue-web.vercel.app
2 stars 0 forks source link

16. firebase #16

Open zyuan8591 opened 1 year ago

zyuan8591 commented 1 year ago

getValue

ref:取得對應資料庫位址 onValue:資料有變更時會執行 cb

const db = getDatabase(app);
const starCountRef = ref(db, `users/${userInfo.uid}`);
onValue(starCountRef, (snapshot) => {
  const data = snapshot.val();
  console.log(data);
});

updateValue

set:更新對應位址資料

const updateUserInfo = () => {
  set(ref(db, "users/" + userInfo.uid), {
    username: userInfo.name,
    email: "kk@test.com",
    // profile_picture: userInfo.photo,
  });
};