CollectionReference class

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

See: firebase.google.com/docs/reference/js/firebase.firestore.CollectionReference.

Inheritance
  • Object
  • Query<CollectionReferenceJsImpl>
  • CollectionReference

Constructors

CollectionReference()
Creates a new CollectionReference
factory

Properties

firestore Firestore
Non-null Firestore for the Cloud Firestore database (useful for performing transactions, etc.).
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
id String
The collection's identifier.
no setter
jsObject → CollectionReferenceJsImpl
JS object.
finalinherited
onSnapshot Stream<QuerySnapshot>
Attaches a listener for QuerySnapshot events.
no setterinherited
onSnapshotMetadata Stream<QuerySnapshot>
Attaches a listener for QuerySnapshot events.
no setterinherited
parent DocumentReference
Nullable reference to the containing DocumentReference if this is a subcollection. If this isn't a subcollection, the reference is null.
no setter
path String
The collection's path.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(Map<String, dynamic> data) Future<DocumentReference>
Adds a new document to this collection with the specified data, assigning it a document ID automatically.
doc([String? documentPath]) DocumentReference
Gets a DocumentReference for the document within the collection at the specified path. If no documentPath is specified, an automatically-generated unique ID will be used for the returned DocumentReference.
endAt({DocumentSnapshot? snapshot, List? fieldValues}) Query<QueryJsImpl>
Creates a new Query where the results end at the provided document (inclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query.
inherited
endBefore({DocumentSnapshot? snapshot, List? fieldValues}) Query<QueryJsImpl>
Creates a new Query where the results end before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query.
inherited
get() Future<QuerySnapshot>
Executes the query and returns the results as a QuerySnapshot.
inherited
isEqual(CollectionReference other) bool
limit(num limit) Query<QueryJsImpl>
Creates a new Query where the results are limited to the specified number of documents.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
orderBy(dynamic fieldPath, [String? directionStr]) Query<QueryJsImpl>
Creates a new Query where the results are sorted by the specified field, in descending or ascending order.
inherited
startAfter({DocumentSnapshot? snapshot, List? fieldValues}) Query<QueryJsImpl>
Creates a new Query where the results start after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query.
inherited
startAt({DocumentSnapshot? snapshot, List? fieldValues}) Query<QueryJsImpl>
Creates a new Query where the results start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query.
inherited
toString() String
A string representation of this object.
inherited
where(dynamic fieldPath, String opStr, dynamic value) Query<QueryJsImpl>
Creates a new Query that returns only documents that include the specified fields and where the values satisfy the constraints provided.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

getInstance(CollectionReferenceJsImpl jsObject) CollectionReference
Creates a new CollectionReference from a jsObject.