Merhaba Javascript Dashboardıma Nasıl Kullanıcı Profili Eklerim ?

McdKsr

Kayıtlı Kullanıcı
Katılım
6 Ara 2020
Mesajlar
80
Tepkime puanı
28
Puanları
18
Merhaba Benim FireBase Bağladıgım Bİ Javascript Dashboardıma Kullanıcı profil sayfası eklemek istiyoru mayrdım ederseniz sevinirim
 

sem10line

LogoMerkezi.com
Moderatör
T.C. Onaylı
Katılım
9 Ara 2020
Mesajlar
374
Tepkime puanı
334
Puanları
93
Yaş
32
Konum
Üsküdar/İstanbul
Web sitesi
www.logomerkezi.com
Firestore'da bunun gibi belge oluşturun

Kod:
DocumentReference docRef = firebaseFirestore.collection(userId).document("Profile");



    docRef.get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {

        @Override

        public void onSuccess(DocumentSnapshot documentSnapshot) {

            if (documentSnapshot.exists()) {

                Log.v(TAG, "Profile exist");

                getProfileData();

            } else {

                Log.v(TAG, "Profile is not exist");

                firebaseFirestore.collection(userId).document("Profile").set(profileEntity);

            }

        }

    });

Profil belgesi yoksa, yeni bir tane oluşturacaktır. Verileri profil varlığında saklayın ve profil belgesine göre kaydedin.

Profil belgesi mevcutsa:

Kod:
private void getProfileData() {

    DocumentReference docRef = firebaseFirestore.collection(userId).document("Profile");

    docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {

        @Override

        public void onComplete(@NonNull Task<DocumentSnapshot> task) {

            if (task.isSuccessful()) {

                DocumentSnapshot document = task.getResult();

                if (document != null) {

                    ProfileEntity profileEntity = task.getResult().toObject(ProfileEntity.class);



                    if (profileEntity != null) {

                       //show your profile data

                    }

                } else {

                    Log.d(TAG, "No such document");

                }

            } else {

                Log.d(TAG, "get failed with ", task.getException());

            }

        }

    });

}
Sizin için bir araştırma yaptım ve elde ettiğim sonuçda 'nin cevabı işe yarayacaktır.
 

McdKsr

Kayıtlı Kullanıcı
Katılım
6 Ara 2020
Mesajlar
80
Tepkime puanı
28
Puanları
18
saol teşekkürler
 
5,683Konular
16,874Mesajlar
9,750Kullanıcılar
obbproSon üye
Üst