本文整理汇总了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)