DocumentChange interface
Stay organized with collections
Save and categorize content based on your preferences.
A DocumentChange
represents a change to the documents matching a query. It contains the document affected and the type of change that occurred.
Signature:
export declare interface DocumentChange<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData>
Properties
Property |
Type |
Description |
doc |
QueryDocumentSnapshot<AppModelType, DbModelType> |
The document affected by this change. |
newIndex |
number |
The index of the changed document in the result set immediately after this DocumentChange (i.e. supposing that all prior DocumentChange objects and the current DocumentChange object have been applied). Is -1 for 'removed' events. |
oldIndex |
number |
The index of the changed document in the result set immediately prior to this DocumentChange (i.e. supposing that all prior DocumentChange objects have been applied). Is -1 for 'added' events. |
type |
DocumentChangeType |
The type of change ('added', 'modified', or 'removed'). |
DocumentChange.doc
The document affected by this change.
Signature:
readonly doc: QueryDocumentSnapshot<AppModelType, DbModelType>;
DocumentChange.newIndex
The index of the changed document in the result set immediately after this DocumentChange
(i.e. supposing that all prior DocumentChange
objects and the current DocumentChange
object have been applied). Is -1 for 'removed' events.
Signature:
readonly newIndex: number;
DocumentChange.oldIndex
The index of the changed document in the result set immediately prior to this DocumentChange
(i.e. supposing that all prior DocumentChange
objects have been applied). Is -1
for 'added' events.
Signature:
readonly oldIndex: number;
DocumentChange.type
The type of change ('added', 'modified', or 'removed').
Signature:
readonly type: DocumentChangeType;
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-07-07 UTC.
[null,null,["Last updated 2023-07-07 UTC."],[],[],null,["# DocumentChange interface\n\nA `DocumentChange` represents a change to the documents matching a query. It contains the document affected and the type of change that occurred.\n\n**Signature:** \n\n export declare interface DocumentChange\u003cAppModelType = DocumentData, DbModelType extends DocumentData = DocumentData\u003e \n\nProperties\n----------\n\n| Property | Type | Description |\n|-------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [doc](./firestore_.documentchange.md#documentchangedoc) | [QueryDocumentSnapshot](./firestore_.querydocumentsnapshot.md#querydocumentsnapshot_class)\\\u003cAppModelType, DbModelType\\\u003e | The document affected by this change. |\n| [newIndex](./firestore_.documentchange.md#documentchangenewindex) | number | The index of the changed document in the result set immediately after this `DocumentChange` (i.e. supposing that all prior `DocumentChange` objects and the current `DocumentChange` object have been applied). Is -1 for 'removed' events. |\n| [oldIndex](./firestore_.documentchange.md#documentchangeoldindex) | number | The index of the changed document in the result set immediately prior to this `DocumentChange` (i.e. supposing that all prior `DocumentChange` objects have been applied). Is `-1` for 'added' events. |\n| [type](./firestore_.documentchange.md#documentchangetype) | [DocumentChangeType](./firestore_.md#documentchangetype) | The type of change ('added', 'modified', or 'removed'). |\n\nDocumentChange.doc\n------------------\n\nThe document affected by this change.\n\n**Signature:** \n\n readonly doc: QueryDocumentSnapshot\u003cAppModelType, DbModelType\u003e;\n\nDocumentChange.newIndex\n-----------------------\n\nThe index of the changed document in the result set immediately after this `DocumentChange` (i.e. supposing that all prior `DocumentChange` objects and the current `DocumentChange` object have been applied). Is -1 for 'removed' events.\n\n**Signature:** \n\n readonly newIndex: number;\n\nDocumentChange.oldIndex\n-----------------------\n\nThe index of the changed document in the result set immediately prior to this `DocumentChange` (i.e. supposing that all prior `DocumentChange` objects have been applied). Is `-1` for 'added' events.\n\n**Signature:** \n\n readonly oldIndex: number;\n\nDocumentChange.type\n-------------------\n\nThe type of change ('added', 'modified', or 'removed').\n\n**Signature:** \n\n readonly type: DocumentChangeType;"]]