本文介绍了如何避免在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个查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 06:04
查看更多