Packagecom.myflashlab.air.extensions.firebase.firestore
Classpublic class DocumentReference
InheritanceDocumentReference Inheritance flash.events.EventDispatcher

A DocumentReference refers to a document location in a Firestore database and can be used to write, read, or listen to the location. There may or may not exist a document at the referenced location. A DocumentReference can also be used to create a CollectionReference to a subcollection.



Public Properties
 PropertyDefined By
  documentId : String
[read-only]
DocumentReference
  parent : CollectionReference
[read-only] Gets a CollectionReference to the collection that contains this document.
DocumentReference
  path : String
[read-only] Gets the path of this document (relative to the root of the database) as a slash-separated string.
DocumentReference
Public Methods
 MethodDefined By
  
addEventListener($type:String, $listener:Function, $useCapture:Boolean = false, $priority:int = 0, $useWeakReference:Boolean = false):void
[override]
DocumentReference
  
addSnapshotListener($onSuccess:Function, $onFailure:Function, $metadataChanges:String = null):void
Starts listening to the document referenced by this DocumentReference with the given options.
DocumentReference
  
collection($collectionPath:String):CollectionReference
Gets a CollectionReference instance that refers to the subcollection at the specified path relative to this document.
DocumentReference
  
omit():void
Deletes the document referred to by this DocumentReference.
DocumentReference
  
read($source:String):void
Reads the document referenced by this DocumentReference.
DocumentReference
  
removeEventListener($type:String, $listener:Function, $useCapture:Boolean = false):void
[override]
DocumentReference
  
removeSnapshotListener($onSuccess:Function, $onFailure:Function):void
remove an already registered snapshotListener.
DocumentReference
  
update($data:Object):void
Updates fields in the document referred to by this DocumentReference.
DocumentReference
  
write($data:Object, $options:SetOptions = null):void
Writes to the document referred to by this DocumentReference.
DocumentReference
Property Detail
documentIdproperty
documentId:String  [read-only]


Implementation
    public function get documentId():String
parentproperty 
parent:CollectionReference  [read-only]

Gets a CollectionReference to the collection that contains this document.


Implementation
    public function get parent():CollectionReference
pathproperty 
path:String  [read-only]

Gets the path of this document (relative to the root of the database) as a slash-separated string.


Implementation
    public function get path():String
Method Detail
addEventListener()method
override public function addEventListener($type:String, $listener:Function, $useCapture:Boolean = false, $priority:int = 0, $useWeakReference:Boolean = false):void

Parameters

$type:String
 
$listener:Function
 
$useCapture:Boolean (default = false)
 
$priority:int (default = 0)
 
$useWeakReference:Boolean (default = false)

addSnapshotListener()method 
public function addSnapshotListener($onSuccess:Function, $onFailure:Function, $metadataChanges:String = null):void

Starts listening to the document referenced by this DocumentReference with the given options. (options can be null).

Parameters

$onSuccess:Function — The function to be called when data is retrived successfully. This function expects "one" parameter as follow. function onSnapshotListenerSuccess(e:FirestoreEvents):void Then you can use e.documentSnapshot to access the received snapshot.
 
$onFailure:Function — The function to be called when there is an error. This function expects "one" parameter as follow. function onSnapshotListenerFailure(e:FirestoreEvents):void Then you can use e.msg to see the error message.
 
$metadataChanges:String (default = null) — Indicates whether metadata-only changes should trigger snapshot events or not.


Example
The following example shows how to work with transactions.
     myDocument.addSnapshotListener(onSnapshotListenerSuccess, onSnapshotListenerFailure);
     function onSnapshotListenerSuccess(e:FirestoreEvents):void
     {
         trace("onSnapshotListenerSuccess: "+JSON.stringify(e.documentSnapshot.data));
     }
      
     function onSnapshotListenerFailure(e:FirestoreEvents):void
     {
         trace("onSnapshotListenerFailure: "+e.msg);
     }
     
collection()method 
public function collection($collectionPath:String):CollectionReference

Gets a CollectionReference instance that refers to the subcollection at the specified path relative to this document.

Parameters

$collectionPath:String — A slash-separated relative path to a subcollection.

Returns
CollectionReference — The CollectionReference instance.
omit()method 
public function omit():void

Deletes the document referred to by this DocumentReference. Result will be dispatched with FirestoreEvents.DOCUMENT_DELETE_FAILURE or FirestoreEvents.DOCUMENT_DELETE_SUCCESS

read()method 
public function read($source:String):void

Reads the document referenced by this DocumentReference. Result will be dispatched with FirestoreEvents.DOCUMENT_GET_FAILURE or FirestoreEvents.DOCUMENT_GET_SUCCESS

Parameters

$source:String (default = NaN)

removeEventListener()method 
override public function removeEventListener($type:String, $listener:Function, $useCapture:Boolean = false):void

Parameters

$type:String
 
$listener:Function
 
$useCapture:Boolean (default = false)

removeSnapshotListener()method 
public function removeSnapshotListener($onSuccess:Function, $onFailure:Function):void

remove an already registered snapshotListener.

Parameters

$onSuccess:Function
 
$onFailure:Function

update()method 
public function update($data:Object):void

Updates fields in the document referred to by this DocumentReference. If no document exists yet, the update will fail. Result will be dispatched with FirestoreEvents.DOCUMENT_UPDATE_FAILURE or FirestoreEvents.DOCUMENT_UPDATE_SUCCESS

Parameters

$data:Object — An object of field / value pairs to update. Fields can contain dots to reference nested fields within the document.

write()method 
public function write($data:Object, $options:SetOptions = null):void

Writes to the document referred to by this DocumentReference. If the document does not yet exist, it will be created. If you pass SetOptions, the provided data can be merged into an existing document. Result will be dispatched with FirestoreEvents.DOCUMENT_SET_FAILURE or FirestoreEvents.DOCUMENT_SET_SUCCESS

Parameters

$data:Object — An object of the fields and values for the document.
 
$options:SetOptions (default = null) — An object to configure the set behavior.