CollectionReference class Null safety

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.).
read-only, inherited
hashCode int
The hash code for this object. [...]
read-only, inherited
id String
The collection's identifier.
read-only
jsObject → CollectionReferenceJsImpl
JS object.
final, inherited
onSnapshot Stream<QuerySnapshot>
Attaches a listener for QuerySnapshot events.
read-only, inherited
onSnapshotMetadata Stream<QuerySnapshot>
Attaches a listener for QuerySnapshot events.
read-only, inherited
parent DocumentReference
Nullable reference to the containing DocumentReference if this is a subcollection. If this isn't a subcollection, the reference is null.
read-only
path String
The collection's path.
read-only
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

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 non-existent 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.