您能否告诉我如何在Firestore查询下进行优化?您可以看到我必须执行2 DB请求才能执行更新操作。我不能使用单一请求或?
async updateProjectOfOwnerMember(id: string, project: Project): Promise<void> {
let finalProjects: Project[];
const querySnapshot = await this.authenticationProvider.firestoreDb.collection("members").where("id", "==", id).get();
querySnapshot.forEach((doc: any) => {
const currentProjects: Project[] = doc.exists ? doc.data().projects : [];
finalProjects = filter(currentProjects, (p: Project) => { return p.id != project.id; });//projects Without Updated Project
finalProjects.push(project);
});
await this.fireStore.doc(`members/${id}`).update({ projects: finalProjects, isOwner: true });
}