Class: Google::Cloud::Firestore::DocumentChange
- Inherits:
-
Object
- Object
- Google::Cloud::Firestore::DocumentChange
- Defined in:
- lib/google/cloud/firestore/document_change.rb
Overview
DocumentChange
A DocumentChange object represents a change to the document matching a query. It contains the document affected and the type of change that occurred (added, modifed, or removed).
See Query#listen and QuerySnapshot#changes.
Instance Method Summary collapse
-
#added? ⇒ Boolean
Determines whether the document was added.
-
#doc ⇒ DocumentSnapshot
(also: #document)
The document snapshot object for the data.
-
#modified? ⇒ Boolean
Determines whether the document was modified.
-
#new_index ⇒ Integer?
The index in the documents array after the change.
-
#old_index ⇒ Integer?
The index in the documents array prior to the change.
-
#removed? ⇒ Boolean
Determines whether the document was removed.
-
#type ⇒ Symbol
The type of change (':added', ':modified', or ':removed').
Instance Method Details
#added? ⇒ Boolean
Determines whether the document was added.
71 72 73 |
# File 'lib/google/cloud/firestore/document_change.rb', line 71 def added? type == :added end |
#doc ⇒ DocumentSnapshot Also known as: document
The document snapshot object for the data.
50 51 52 |
# File 'lib/google/cloud/firestore/document_change.rb', line 50 def doc @doc end |
#modified? ⇒ Boolean
Determines whether the document was modified.
80 81 82 |
# File 'lib/google/cloud/firestore/document_change.rb', line 80 def modified? type == :modified end |
#new_index ⇒ Integer?
The index in the documents array after the change.
107 108 109 |
# File 'lib/google/cloud/firestore/document_change.rb', line 107 def new_index @new_index end |
#old_index ⇒ Integer?
The index in the documents array prior to the change.
98 99 100 |
# File 'lib/google/cloud/firestore/document_change.rb', line 98 def old_index @old_index end |
#removed? ⇒ Boolean
Determines whether the document was removed.
89 90 91 |
# File 'lib/google/cloud/firestore/document_change.rb', line 89 def removed? type == :removed end |
#type ⇒ Symbol
The type of change (':added', ':modified', or ':removed').
60 61 62 63 64 |
# File 'lib/google/cloud/firestore/document_change.rb', line 60 def type return :removed if @new_index.nil? return :added if @old_index.nil? :modified end |