Firebase 获取新创建的数据
是否可以通过AngularFire2从Firebase获取您刚刚保存的数据? 我想保存生成UUID的数据 我这样保存数据:Firebase 获取新创建的数据,firebase,angularfire2,Firebase,Angularfire2,是否可以通过AngularFire2从Firebase获取您刚刚保存的数据? 我想保存生成UUID的数据 我这样保存数据: const phase = this.fireStore.collection("pr").doc(prId).collection("col1").doc(phase) phase.collection("content").add({"content": post.content}) const phase = this.fireStore.colle
const phase = this.fireStore.collection("pr").doc(prId).collection("col1").doc(phase)
phase.collection("content").add({"content": post.content})
const phase = this.fireStore.collection("projects").doc(post.projectId).collection("canvas1").doc(post.phase)
return from(phase.collection("content").add({ "content": post.content })).pipe(map(ref => {
return new Post(ref.id, post.content)
}))
现在,我想将保存的数据作为一个可观察对象返回,该对象有一个自定义对象的映射
我现在拥有的是,我首先把它转换成一个可观察的,然后我通过valueChanges做get
对我来说,这似乎太过分了。我要这样做:
const phase = this.fireStore.collection("pr").doc(prId).collection("col1").doc(phase)
phase.collection("content").add({"content": post.content})
const phase = this.fireStore.collection("projects").doc(post.projectId).collection("canvas1").doc(post.phase)
return from(phase.collection("content").add({ "content": post.content })).pipe(map(ref => {
return new Post(ref.id, post.content)
}))
如果有人知道更好的方法,请分享:-),或者你必须在添加新数据之前订阅“this.fireStore.collection”(“pr”).doc(prId).col1”,当你刚刚添加新内容时取消订阅。这真的是最好的选择吗?我也在等待另一个选择。。