Cloud Firestoreはベータ版です。 Googleでは利用可能な情報が少なくなっています。 私は、特定のコレクションに存在する文書の総数をどのように得ることができるのかを知りたいだけです。私たちはforeachループでこれを行うことができますが、これは私が考えるように良い方法ではありません。私はlength
機能を試しましたが、機能しません。Cloud FirestoreはIonic 3の文書数を取得します
import {AngularFirestore} from 'angularfire2/firestore';
........
constructor(private afs:AngularFirestore) {
console.log(this.afs.collection(`/cart`).length); //undefined
let ref = this.afs.collection('/cart').valueChanges();
ref.forEach(element => {
console.log(element.length); // total 4 (works fine)
});
}
あなたの迅速な対応に感謝します。今私が上記のコードを実行すると、エラー 'this.afs.collection(...)が返されます。getは関数ではありません。私は私のプロジェクトに 'angularfire2'を使っています。 –
アップデートを参照してください。 – Sampath
これはうまくいきません。その関数は '.map();'の中にないようです。 countはobjcetを返しています。コードが 'c.length'に到達していません。 –