| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

「Cloud Firestore」の版間の差分

提供: MyMemoWiki
ナビゲーションに移動 検索に移動
13行目: 13行目:
 
import { Observable } from 'rxjs';
 
import { Observable } from 'rxjs';
 
import { AngularFirestore, QuerySnapshot, DocumentSnapshot, DocumentData } from '@angular/fire/firestore';
 
import { AngularFirestore, QuerySnapshot, DocumentSnapshot, DocumentData } from '@angular/fire/firestore';
 +
 +
export const FS_PATH_INFORMATIONS = 'informations/';
  
 
constructor(
 
constructor(

2020年9月11日 (金) 15:58時点における版

| Angular | Firebase | TypeScript | Google Cloud Platform | ブログカテゴリ(Firebase) |

データの並べ替え

AngularFire

Collection

  1. import { Observable } from 'rxjs';
  2. import { AngularFirestore, QuerySnapshot, DocumentSnapshot, DocumentData } from '@angular/fire/firestore';
  3.  
  4. export const FS_PATH_INFORMATIONS = 'informations/';
  5.  
  6. constructor(
  7. public firestore: AngularFirestore
  8. ) { }
  9.  
  10. public getInformations(user?: User): Observable<QuerySnapshot<DocumentData>> {
  11. const path = `${FS_PATH_INFORMATIONS}`;
  12. console.log(`get informations..[${path}]`);
  13. return this.firestore.collection<InformationCard>(path).get();
  14. }
  1. ngOnInit(): void {
  2. let outer = this;
  3. this.bookService.getInformations().subscribe({
  4. next(p){
  5. p.forEach(d => {
  6. outer.infoCards.push(d.data() as InformationCard);
  7. });
  8. }
  9. });
  10. }