當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript AngularFirestore.doc方法代碼示例

本文整理匯總了TypeScript中@angular/fire/firestore.AngularFirestore.doc方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript AngularFirestore.doc方法的具體用法?TypeScript AngularFirestore.doc怎麽用?TypeScript AngularFirestore.doc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@angular/fire/firestore.AngularFirestore的用法示例。


在下文中一共展示了AngularFirestore.doc方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

      db.object('PERRINNTeams/' + this.UI.currentTeam + '/chatReplayMode').valueChanges().subscribe(snapshot => {
        if (snapshot != undefined) {
          this.chatReplayMode = snapshot ? true : false;
        }
        this.previousMessageTimestamp = 0;
        this.previousMessageUser = '';
        this.draftMessageDB = false;
        this.draftImage = '';
        this.draftImageDownloadURL = '';
        this.draftMessage = '';
        this.messageNumberDisplay = 15;
        this.teamMessages = this.db.list('teamMessages/' + this.UI.currentTeam, ref => ref.limitToLast(this.messageNumberDisplay)).snapshotChanges().pipe(map(changes => {
          this.UI.loading = false;
          const updateObj = {};
          changes.forEach(c => {
            updateObj['teamReads/' + this.UI.currentUser + '/' + this.UI.currentTeam + '/' + c.payload.key] = true;
          });
          this.db.database.ref().update(updateObj);
          return changes.map(c => ({key: c.payload.key, values: c.payload.val()}));
        }));
        if (this.chatReplayMode) {
          this.chatReplayLoop();
        }
        this.draftMessageUsers = this.db.list('teamActivities/' + this.UI.currentTeam + '/draftMessages/').snapshotChanges().pipe(map(changes => {
          return changes.map(c => ({key: c.payload.key, values: c.payload.val()}));
        }));

        afs.doc<any>('PERRINNTeams/'+this.UI.currentUser+'/viewTeams/'+this.UI.currentTeam).valueChanges().subscribe(userTeam => {
          if (userTeam!=null&&userTeam.lastChatVisitTimestamp!=undefined) {this.lastChatVisitTimestamp = Number(userTeam.lastChatVisitTimestamp); }
          else this.lastChatVisitTimestamp=0;
        });
      });
開發者ID:PERRINN,項目名稱:client-web,代碼行數:32,代碼來源:chat.component.ts

示例2: switchMap

 switchMap(user => {
   if (user) {
     return this.afs.doc<User>(`users/${user.uid}`).valueChanges();
   } else {
     return of(null);
   }
 })
開發者ID:geeksmarter,項目名稱:andrews.codes,代碼行數:7,代碼來源:auth.service.ts

示例3: switchMap

 switchMap((user: any) => {
   if (user) {
     this.userId = user.uid;
     return this.afs.doc<IUser>(`users/${user.uid}`).valueChanges();
   } else {
     return of(null);
   }
 })
開發者ID:Meistercoach83,項目名稱:sfw,代碼行數:8,代碼來源:auth.service.ts

示例4: switchMap

 switchMap(user => {
     if (user) {
         Sentry.configureScope((scope) => {
             scope.setUser({ 'email': user.email });
         });
         return this.afs.doc<User>(`users/${user.uid}`).valueChanges();
     } else {
         return of(null);
     }
 }),
開發者ID:jacobbowdoin,項目名稱:RapidWords,代碼行數:10,代碼來源:auth.service.ts

示例5: followTeam

 followTeam(teamID: string, userID: string) {
   const now = Date.now();
   this.afs.doc<any>('PERRINNTeams/'+userID+/viewTeams/+teamID).update({
     lastChatVisitTimestamp: now,
     name: this.UI.currentTeamObj.name,
     imageUrlThumb: this.UI.currentTeamObj.imageUrlThumb ? this.UI.currentTeamObj.imageUrlThumb : '',
   });
   this.db.object('subscribeTeamUsers/' + teamID).update({
     [userID]: true,
   });
 }
開發者ID:PERRINN,項目名稱:client-web,代碼行數:11,代碼來源:chat.component.ts

示例6: updateUserData

    private updateUserData(user, enteredName?: string) {
        const userRef: AngularFirestoreDocument<any> = this.afs.doc(`users/${user.uid}`);

        const data: User = {
            uid: user.uid,
            email: user.email,
            displayName: user.displayName || enteredName,
            photoURL: user.photoURL || null,
        };

        return userRef.set(data, { merge: true });
    }
開發者ID:jacobbowdoin,項目名稱:RapidWords,代碼行數:12,代碼來源:auth.service.ts

示例7: timestampChatVisit

 timestampChatVisit() {
   if (this.currentTeamObjKey != this.currentTeam) {return; }
   const now = Date.now();
   this.afs.doc<any>('PERRINNTeams/'+this.currentUser+/viewTeams/+this.currentTeam).update({
     lastChatVisitTimestamp: now,
     name: this.currentTeamObj.name,
     imageUrlThumb: this.currentTeamObj.imageUrlThumb ? this.currentTeamObj.imageUrlThumb : '',
   });
   this.db.object('subscribeTeamUsers/' + this.currentTeam).update({
     [this.currentUser]: true,
   });
 }
開發者ID:PERRINN,項目名稱:client-web,代碼行數:12,代碼來源:userInterface.service.ts

示例8: updateUserData

  // Sets user data to firestore after succesful login
  private updateUserData(user: User) {
    const userRef: AngularFirestoreDocument<User> = this.afs.doc(
      `users/${user.uid}`
    );

    const data: User = {
      uid: user.uid,
      email: user.email || null,
      displayName: user.displayName || 'Anon',
      photoURL: user.photoURL || 'https://api.adorable.io/avatars/100/andrews.codes.png'
    };
    return userRef.set(data);
  }
開發者ID:geeksmarter,項目名稱:andrews.codes,代碼行數:14,代碼來源:auth.service.ts

示例9: SetUserData

 SetUserData(user) {
   const userRef: AngularFirestoreDocument<any> = this.afs.doc(`users/${user.uid}`);
   const userData: User = {
     uid: user.uid,
     email: user.email,
     displayName: user.displayName,
     photoURL: user.photoURL,
     emailVerified: user.emailVerified
   };
   return userRef.set(userData, {
     merge: true
   });
 }
開發者ID:niawjunior,項目名稱:blog,代碼行數:13,代碼來源:auth.service.ts

示例10: toggleSetting

 public async toggleSetting(setting: string, value: boolean) {
   try {
     const newSetting = { [setting]: !value };
     const dictionary = await this.dictionariesService.currentDictionary.pipe(first()).toPromise();
     await this.afs.doc(`dictionaries/${dictionary.id}/config/settings`).set(newSetting, { merge: true });
     this.snackBar.open('Setting updated', '', { duration: 2000 });
   } catch (err) {
     this.snackBar.open('Failed to update setting.', '', {
       panelClass: 'snackbar-error',
       duration: 3000
     });
   }
 }
開發者ID:jacobbowdoin,項目名稱:RapidWords,代碼行數:13,代碼來源:settings.service.ts


注:本文中的@angular/fire/firestore.AngularFirestore.doc方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。