当前位置: 首页>>代码示例>>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;未经允许,请勿转载。