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


TypeScript AngularFirestore.collection方法代碼示例

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


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

示例1: constructor

 constructor(private afs: AngularFirestore, private authService: AuthService) {
   this.usersCollection = afs.collection<User>('users');
   this.user = this.usersCollection.snapshotChanges().pipe(
     map(actions => actions.map(a => {
       const data = a.payload.doc.data() as User;
       const id = a.payload.doc.id;
       return { id, ...data };
     }))
   );
   this.redCollection = afs.collection<Red>('red');
   this.red = this.redCollection.snapshotChanges().pipe(
     map(actions => actions.map(a => {
       const data = a.payload.doc.data() as Red;
       const id = a.payload.doc.id;
       return { id, ...data };
     }))
   );
   this.coorCollection = afs.collection<Coordenadas>('coordenadas');
   this.coor = this.coorCollection.snapshotChanges().pipe(
     map(actions => actions.map(a => {
       const data = a.payload.doc.data() as Coordenadas;
       const id = a.payload.doc.id;
       return { id, ...data };
     }))
   );
 }
開發者ID:nahytar,項目名稱:app_fem-,代碼行數:26,代碼來源:database.service.ts

示例2: if

 this.afAuth.user.subscribe((auth) => {
   if (auth != null) {
     this.currentUser = auth.uid;
     this.db.object('PERRINNTeams/' + this.currentUser).valueChanges().subscribe(snapshot => {
       this.currentUserObj = snapshot;
     });
     afs.collection<any>('PERRINNTeams/'+this.currentUser+'/viewTeams/').valueChanges().subscribe(snapshot => {
       this.currentUserTeamsObj = snapshot;
       this.globalChatActivity = false;
       snapshot.forEach(userTeam => {
         let chatActivity:boolean=false;
         if(userTeam.lastChatVisitTimestamp!=undefined)chatActivity=(userTeam.lastMessageTimestamp>userTeam.lastChatVisitTimestamp);
         else if(userTeam.lastMessageTimestamp!=undefined)chatActivity=true;
         else chatActivity=false;
         if (chatActivity) {
           this.globalChatActivity = true;
         }
         document.title = this.globalChatActivity ? '(!) PERRINN' : 'PERRINN';
       });
     });
     if (this.focusUser == null) { this.focusUser = auth.uid; }
     this.db.database.ref('appSettings/PERRINNServices/').once('value').then(services => {
       this.services = services;
     });
   } else {
     this.currentUser = null;
     this.focusUser = null;
     this.currentTeam = null;
   }
 });
開發者ID:PERRINN,項目名稱:client-web,代碼行數:30,代碼來源:userInterface.service.ts

示例3: ngOnInit

 ngOnInit() {
   const currentUser = this.db.collection('users', user => { return user.where('idToken', '==', 'NF1P7fzo7UYtW7MWXrIQknEVRRL2')})
   .doc('customerInfo');
   currentUser.valueChanges().subscribe(val => {
     console.log(val)
   });
 }
開發者ID:inlines,項目名稱:angular-firebase,代碼行數:7,代碼來源:customer-info.component.ts

示例4: ngOnInit

 ngOnInit() {
   this.rodadas = this.db.collection(config.rodadaDB).snapshotChanges()
   .pipe(map(actions => {
     return actions.map(a => {
       const data = a.payload.doc.data() as Rodada;
       console.log("atualizacao!! - " + JSON.stringify(data));
       const id = a.payload.doc.id;
       return { id, ...data };
     });
   }));
 }
開發者ID:HermanoLeite,項目名稱:fodinha,代碼行數:11,代碼來源:rodada.component.ts

示例5: switchMap

 switchMap((dictionary) => {
   return this.afs.collection<WriteInCollaborator>(`dictionaries/${dictionary.id}/writeInCollaborators`)
     .snapshotChanges().pipe(
       map(arr => {
         return arr.map(snap => {
           const data = snap.payload.doc.data() as WriteInCollaborator;
           const id = snap.payload.doc.id;
           return {
             id, ...data
           };
         });
       }));
 })
開發者ID:jacobbowdoin,項目名稱:RapidWords,代碼行數:13,代碼來源:contributors.service.ts

示例6: map

 this.route.params.subscribe(params => {
   this.UI.focusUser = params.id;
   db.object('PERRINNTeams/' + this.UI.focusUser).valueChanges().subscribe(snapshot => {
     this.UI.focusUserObj = snapshot;
   });
   this.viewTeams=afs.collection('PERRINNTeams').doc(this.UI.focusUser).collection('viewTeams',ref=>ref.orderBy('lastMessageTimestamp','desc')).snapshotChanges().pipe(
     map(actions=>actions.map(a=>{
       const values=a.payload.doc.data();
       const key=a.payload.doc.id;
       this.UI.loading = false;
       return {key,values};
     }))
   );
 });
開發者ID:PERRINN,項目名稱:client-web,代碼行數:14,代碼來源:userProfile.component.ts

示例7: setPageView

 public setPageView(key): void {
   const documentReference = this.afs.collection<ContentDetail>('postDetail').doc(key);
   firebase.firestore().runTransaction(page => {
       return page.get(documentReference.ref)
           .then(doc => {
               const newValue = doc.data().view + 1;
               page.update(documentReference.ref, {
                   view: newValue
               });
           });
   }).catch(() => {
     console.log('error');
   });
 }
開發者ID:niawjunior,項目名稱:blog,代碼行數:14,代碼來源:page-view.service.ts

示例8: alert

    this.storage.get('user').then(({ uid }) => {

      this.afs.collection<User>('users')
        .doc(uid)
        .collection('history')
        .add({ ...info })
        .then(res => {
          console.log(res);

        })
        .catch(err => {
          alert(err);

        })

    });
開發者ID:Microsmsm,項目名稱:Dawaey,代碼行數:16,代碼來源:drug.ts

示例9: incrementHitCount

    route.paramMap.subscribe(async (params: ParamMap) => {
      // short param is definitely defined because we can only here from the
      // route with short defined
      const short = params.get('short') as string;
      const snapshot =
          (await db.collection('links').doc<Link>(short).ref.get());
      const dest = snapshot.data() as Link | undefined;

      if (dest !== undefined) {
        const incrementHitCount =
            fns.httpsCallable<string, void>('callableIncrementHitCount');
        incrementHitCount(short);
        window.location.replace(dest.content);
      } else {
        window.location.replace(environment.baseUrl);
      }
    });
開發者ID:brikr,項目名稱:bthles,代碼行數:17,代碼來源:link-content.component.ts

示例10: loginJobs

  loginJobs() {
    const user = this.afAuth.auth.currentUser;
    const userInfo: User = {
      uid: user.uid,
      displayName: user.displayName,
      email: user.email,
      phoneNumber: user.phoneNumber,
      photoURL: user.photoURL,
      logged:true
    }

    this.afs.
      collection<User>(`users`)
      .doc(user.uid)
      .set({ ...userInfo })
      .then(res => {
        console.log(res);
      }).catch(err => {
        alert(err)
      })
    this.storage.set('user', userInfo)
    this.events.publish('user:login', user)
  }
開發者ID:Microsmsm,項目名稱:Dawaey,代碼行數:23,代碼來源:auth.ts


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