最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to update data in Firebase realtime database using Firebase 9 (modular sdk) - Stack Overflow

programmeradmin3浏览0评论

How do we do this now:

import "firebase/database"

await firebase
        .database()
        .ref('users/' + auth.currentUser.uid)
        .update({
            displayName: displayName
        });

How do we do this now:

import "firebase/database"

await firebase
        .database()
        .ref('users/' + auth.currentUser.uid)
        .update({
            displayName: displayName
        });
Share Improve this question edited May 17, 2021 at 13:23 Nikos asked May 17, 2021 at 7:50 NikosNikos 7,55110 gold badges57 silver badges96 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

That should do:

import firebase from "firebase/pat/app";
import {update, ref, getDatabase} from "firebase/database"

const app = firebase.initializeApp(firebaseConfig);

const db = getDatabase(app)
const dbRef = ref(db, `users/{userUid}`)
update(dbRef, {displayName: "Firebase9_IsCool"}).then(() => {
  console.log("Data updated");
}).catch((e) => {
  console.log(e);
})
发布评论

评论列表(0)

  1. 暂无评论