Collection

public final class: Collection
extends Query
java.lang.Object
   ↳ com.google.firebase.firestore.Query
     ↳ com.google.firebase.firestore.Collection

Class Overview

A Collection can be used for adding documents, getting document references, and querying for documents (using the methods inherited from Query).

Summary

Public Methods
Task<DocumentReference> add(Map<String, Object> data)
Adds a new document to this collection with the specified data, assigning it a document ID automatically.
Task<DocumentReference> add(Object pojo)
Adds a new document to this collection with the specified POJO as contents, assigning it a document ID automatically.
Collection collection(String documentId, String collectionName)
Returns a Collection referring to the collection at the specified path, relative to this collection.
DocumentReference document()
Returns a DocumentReference pointing to a new document with an auto-generated ID within this collection.
DocumentReference document(String documentId)
Returns a DocumentReference for the given documentId within this collection.
String getName()
Returns the name of the collection
Inherited Methods
From class com.google.firebase.firestore.Query
From class java.lang.Object

Public Methods

public Task<DocumentReference> add (Map<String, Object> data)

Adds a new document to this collection with the specified data, assigning it a document ID automatically.

Parameters
data Map: A Map containing the data for the new document.
Returns
Task<DocumentReference> A Task that will be resolved with the DocumentReference of the newly created document.

public Task<DocumentReference> add (Object pojo)

Adds a new document to this collection with the specified POJO as contents, assigning it a document ID automatically.

Parameters
pojo Object: The POJO that will be used to populate the contents of the document
Returns
Task<DocumentReference> A Task that will be resolved with the DocumentReference of the newly created document.

public Collection collection (String documentId, String collectionName)

Returns a Collection referring to the collection at the specified path, relative to this collection.

Parameters
documentId String: The documentId
collectionName String: The name of the subcollection.
Returns
Collection The Collection at the specified collectionPath.

public DocumentReference document ()

Returns a DocumentReference pointing to a new document with an auto-generated ID within this collection.

Returns
DocumentReference A DocumentReference pointing to a new document with an auto-generated ID.

public DocumentReference document (String documentId)

Returns a DocumentReference for the given documentId within this collection.

Parameters
documentId String: The document id to get a reference for.
Returns
DocumentReference An instance of DocumentReference for the given documentID.

public String getName ()

Returns the name of the collection

Returns
String The name of the collection

Send feedback about...

Need help? Visit our support page.