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


TypeScript firestore.AngularFirestoreCollection類代碼示例

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


在下文中一共展示了AngularFirestoreCollection類的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: criarRodada

    async criarRodada(jogadoresParticipantes, jogoId, rodadaNro) {
        var count = 0;
        
        const jogadorComeca = rodadaNro >= jogadoresParticipantes.length ? rodadaNro % jogadoresParticipantes.length : rodadaNro;
        var rodadaDoc = this.jogos.doc(jogoId).collection("rodadas").doc(rodadaNro.toString());
        
        await new Promise(resolve => {
            rodadaDoc.set({
                manilha: null,
                comeca: jogadorComeca,
                vez: jogadorComeca,
                etapa: Etapa.embaralhar,
                jogadoresCount: jogadoresParticipantes.length
            }).then(res => resolve());
        });
        
        jogadoresParticipantes.forEach(jogador => {
            rodadaDoc.collection("jogadores").doc(count.toString()).set({
                jogadorId: jogador.id,
                nome: jogador.nome,
                cor: jogador.cor,
                fez: 0,
                cartas: null,
                palpite: null
            });
            count++;
        }); 

        this.jogos.doc(jogoId).update({rodada: rodadaNro});
    }
開發者ID:HermanoLeite,項目名稱:fodinha,代碼行數:30,代碼來源:jogo.service.ts

示例3: ngOnInit

 ngOnInit() {
   this.movieCollection = this.userService.getMovieCollection();
   this.movies$ = this.movieCollection.valueChanges().pipe(
     map(Movie.fromFirebaseCollection),
     share()
   );
 }
開發者ID:dArignac,項目名稱:treasury,代碼行數:7,代碼來源:movie-list.component.ts

示例4: createNote

 createNote(content: string) {
   const note = {
     content,
     hearts: 0,
     time: new Date().getTime(),
   };
   return this.notesCollection.add(note);
 }
開發者ID:geeksmarter,項目名稱:andrews.codes,代碼行數:8,代碼來源:notes.service.ts

示例5: getBooks

 getBooks() {
   this.books = this.booksCollection.snapshotChanges().pipe(
       map(collection => collection.map(document => {
           const data = document.payload.doc.data() as Book;
           const id = document.payload.doc.id;
           return { id, ...data };
       })));
   return this.books;
 }
開發者ID:azazely85,項目名稱:angulartech,代碼行數:9,代碼來源:books.service.ts

示例6:

 jogadoresParticipantes.forEach(jogador => {
     this.jogos.doc(id).collection(config.jogadorDB).doc(jogador.id).set({
         nome: jogador.nome,
         cor: jogador.cor,
         vidas: 5,
         removido: false,
         jogando: true
     });
 });
開發者ID:HermanoLeite,項目名稱:fodinha,代碼行數:9,代碼來源:jogo.service.ts

示例7: Promise

 return new Promise(resolve => {
     this.jogos.add(jogo).then(function(docRef) {
         this.cookieService.set("jogoId", docRef.id );
         resolve(docRef.id);
     }.bind(this))
     .catch(function(error) {
         console.error("Error adding document: ", error);
         resolve(null);
     });
 });
開發者ID:HermanoLeite,項目名稱:fodinha,代碼行數:10,代碼來源:jogo.service.ts

示例8: getData

 getData(): Observable<any[]> {
   // ['added', 'modified', 'removed']
   return this.notesCollection.snapshotChanges().pipe(
     map((actions) => {
       return actions.map((a) => {
         const data = a.payload.doc.data();
         return { id: a.payload.doc.id, ...data };
       });
     })
   );
 }
開發者ID:geeksmarter,項目名稱:andrews.codes,代碼行數:11,代碼來源:notes.service.ts

示例9: addrodada

 addrodada(rodada) {
     this.rodadas.add(rodada);
 }
開發者ID:HermanoLeite,項目名稱:fodinha,代碼行數:3,代碼來源:rodada.service.ts

示例10: addCoordenadas

 addCoordenadas(coor: Coordenadas) {
   this.coorCollection.add(coor);
 }
開發者ID:nahytar,項目名稱:app_fem-,代碼行數:3,代碼來源:database.service.ts


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