「Cloud Firestore」の版間の差分
ナビゲーションに移動
検索に移動
| 5行目: | 5行目: | ||
===データの並べ替え=== | ===データの並べ替え=== | ||
*https://firebase.google.com/docs/firestore/query-data/order-limit-data?hl=ja | *https://firebase.google.com/docs/firestore/query-data/order-limit-data?hl=ja | ||
| − | + | ==AngularFire== | |
*https://github.com/angular/angularfire/blob/master/docs/firestore/querying-collections.md | *https://github.com/angular/angularfire/blob/master/docs/firestore/querying-collections.md | ||
| + | |||
| + | ==Collection== | ||
| + | |||
| + | <pre> | ||
| + | import { Observable } from 'rxjs'; | ||
| + | import { AngularFirestore, QuerySnapshot, DocumentSnapshot, DocumentData } from '@angular/fire/firestore'; | ||
| + | |||
| + | constructor( | ||
| + | public firestore: AngularFirestore | ||
| + | ) { } | ||
| + | |||
| + | public getInformations(user?: User): Observable<QuerySnapshot<DocumentData>> { | ||
| + | const path = `${FS_PATH_INFORMATIONS}`; | ||
| + | console.log(`get informations..[${path}]`); | ||
| + | return this.firestore.collection<InformationCard>(path).get(); | ||
| + | } | ||
| + | </pre> | ||
| + | |||
| + | <pre> | ||
| + | ngOnInit(): void { | ||
| + | let outer = this; | ||
| + | this.bookService.getInformations().subscribe({ | ||
| + | next(p){ | ||
| + | p.forEach(d => { | ||
| + | outer.infoCards.push(d.data() as InformationCard); | ||
| + | }); | ||
| + | } | ||
| + | }); | ||
| + | } | ||
| + | </pre> | ||
2020年9月11日 (金) 15:57時点における版
| Angular | Firebase | TypeScript | Google Cloud Platform | ブログカテゴリ(Firebase) |
データの並べ替え
AngularFire
Collection
import { Observable } from 'rxjs';
import { AngularFirestore, QuerySnapshot, DocumentSnapshot, DocumentData } from '@angular/fire/firestore';
constructor(
public firestore: AngularFirestore
) { }
public getInformations(user?: User): Observable<QuerySnapshot<DocumentData>> {
const path = `${FS_PATH_INFORMATIONS}`;
console.log(`get informations..[${path}]`);
return this.firestore.collection<InformationCard>(path).get();
}
ngOnInit(): void {
let outer = this;
this.bookService.getInformations().subscribe({
next(p){
p.forEach(d => {
outer.infoCards.push(d.data() as InformationCard);
});
}
});
}
© 2006 矢木浩人