如何避免在Firestore中进行N + 1个查询?

编程入门 行业动态 更新时间:2024-10-26 06:33:29
本文介绍了如何避免在Firestore中进行N + 1个查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在Mongodb中是否有类似于填充"方法的内容,并且包含在导轨中,因此可以填充与其他文档关联的文档ID,而无需我遍历每个文档并进行单独的查询.

Is there something similar to the "populate" method in Mongodb and includes in rails where Document Id's that are associated with other documents can be populated instead of me having to iterate through each document and make a separate query.

例如,假设我有一个组文档,该组文档具有一个称为成员的集合.并且该集合中的每个文档都对应于一个用户文档的ID.有什么方法可以填充这些文档中的每个文档,而无需我实际进行单独的查询来提取每个ID的用户文档.

For instance let's say that I have a group document that has a collection called members. And each document in that collection corresponds to the ID of a User document. Is there any way to populate each one of those documents, without me actually making a separate query to pull the user document for each of those IDs.

推荐答案

如果要更新集合中文档的内容,则必须查询每个文档,进行迭代,然后分别更新内容.Firestore中没有像SQL这样的更新位置"功能,该功能使您可以在一次操作中更新多个文档.

If you want to update the contents of documents in a collection, you will have to query for each one, iterate them, and update the contents individually. There is no "update where" function in Firestore like SQL that lets you update multiple documents in a single operation.

更多推荐

如何避免在Firestore中进行N + 1个查询?

本文发布于:2023-10-28 05:17:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1535635.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Firestore

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!