| 683 | } |
| 684 | |
| 685 | export class QuerySnapshot implements IQuerySnapshot { |
| 686 | _native: com.google.firebase.firestore.QuerySnapshot; |
| 687 | |
| 688 | static fromNative(snapshot: com.google.firebase.firestore.QuerySnapshot) { |
| 689 | if (snapshot instanceof com.google.firebase.firestore.QuerySnapshot) { |
| 690 | const ss = new QuerySnapshot(); |
| 691 | ss._native = snapshot; |
| 692 | return ss; |
| 693 | } |
| 694 | return null; |
| 695 | } |
| 696 | |
| 697 | get docs() { |
| 698 | const documents = this.native.getDocuments(); |
| 699 | const count = documents.size(); |
| 700 | const docs = []; |
| 701 | for (let i = 0; i < count; i++) { |
| 702 | docs.push(QueryDocumentSnapshot.fromNative(documents.get(i))); |
| 703 | } |
| 704 | return docs; |
| 705 | } |
| 706 | |
| 707 | get empty(): boolean { |
| 708 | return this.native.isEmpty(); |
| 709 | } |
| 710 | |
| 711 | get metadata(): SnapshotMetadata { |
| 712 | return SnapshotMetadata.fromNative(this.native.getMetadata()); |
| 713 | } |
| 714 | |
| 715 | get query() { |
| 716 | return Query.fromNative(this.native.getQuery()); |
| 717 | } |
| 718 | |
| 719 | get size(): number { |
| 720 | return this.native.size(); |
| 721 | } |
| 722 | |
| 723 | docChanges(options?: SnapshotListenOptions): DocumentChange[] { |
| 724 | let changes: java.util.List<com.google.firebase.firestore.DocumentChange>; |
| 725 | if (typeof options?.includeMetadataChanges === 'boolean') { |
| 726 | changes = this.native.getDocumentChanges(com.google.firebase.firestore.MetadataChanges.INCLUDE); |
| 727 | } else { |
| 728 | changes = this.native.getDocumentChanges(); |
| 729 | } |
| 730 | |
| 731 | const count = changes.size(); |
| 732 | const docChanges = []; |
| 733 | for (let i = 0; i < count; i++) { |
| 734 | docChanges.push(DocumentChange.fromNative(changes.get(i))); |
| 735 | } |
| 736 | return docChanges; |
| 737 | } |
| 738 | |
| 739 | forEach(callback: (result: QueryDocumentSnapshot, index: number) => void, thisArg?: any): void { |
| 740 | if (typeof callback === 'function') { |
| 741 | const cb = thisArg ? callback.bind(thisArg) : callback; |
| 742 | const count = this.native.size(); |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…