本文整理匯總了TypeScript中@firebase/firestore-types.CollectionReference類的典型用法代碼示例。如果您正苦於以下問題:TypeScript CollectionReference類的具體用法?TypeScript CollectionReference怎麽用?TypeScript CollectionReference使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了CollectionReference類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: publishDocument
requirements.map(node => {
if (typeof node === "string") {
if (node.startsWith("subprograms")) {
// Resolve the subprogram.
return publishDocument(
this.subprogramsRef.doc(node.split("/")[1])
).pipe(
switchMap(result => {
if (!result) {
console.error("Could not resolve subprogram: " + node);
return of({ display: "Specification error" });
}
return this.resolve(JSON.parse(result.requirements)).pipe(
map(requirements => ({
display: result.display,
requirements
}))
);
})
);
} else {
return of(node);
}
} else if (node.requirements) {
return this.resolve(node.requirements).pipe(
map(requirements => ({ ...node, requirements }))
);
} else {
return of(node);
}
})
示例2:
/**
* Create a reference to a single document in a collection.
* @param path
*/
doc<T>(path: string): AngularFirestoreDocument<T> {
return new AngularFirestoreDocument<T>(this.ref.doc(path), this.afs);
}
示例3: randomName
Array.from(Array(numberOfItems)).forEach((a, i) => {
const name = randomName(firestore);
batch.set(collectionRef.doc(name), FAKE_STOCK_DATA);
names = [...names, name];
});
示例4: add
/**
* Add data to a collection reference.
*
* Note: Data operation methods are done on the reference not the query. This means
* when you update data it is not updating data to the window of your query unless
* the data fits the criteria of the query.
*/
add(data: T): Promise<DocumentReference> {
return this.ref.add(data);
}
示例5:
const observable = Observable.create(observer =>
ref.onSnapshot(observer)