如何在Firestore Swift中创建空集合 [英] How to create empty collection in Firestore Swift

查看:56
本文介绍了如何在Firestore Swift中创建空集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Firestore(Swift)中创建一个空集合?我想在注册数据库用户后创建数据库用户,因为在主屏幕上它试图从不存在的那个集合中获取数据,并且崩溃了

How can I create an empty collection in Firestore (Swift)? i want to do that when I create DB users after I registrate them, because on my main screen it tries to fetch from that collection that doesn't exists and I get a crash

推荐答案

您无法在Cloud Firestore中创建空集合.要解决此问题,您应该在该集合中至少创建一个文档.这样,该特定集合将开始存在.

There is no way you can create an empty collection in Cloud Firestore. To solve this, you should create at least one document within that collection. In this way, that particular collection will start to exist.

如果您在Firebase控制台中创建一个包含一个文档的集合,则将自动为您创建该集合.如果您尝试删除集合中的最后一个文档,也会发生这种情况,该特定集合将被自动删除.

If you create a collection in the Firebase Console containing one document, the collection is created automatically for you. This is also happening if you try to delete the last document in a collection, that particular collection will be automatically deleted.

这篇关于如何在Firestore Swift中创建空集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆