Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Firestore的字段路径无效_Ios_Swift_Firebase_Google Cloud Firestore - Fatal编程技术网

Ios Firestore的字段路径无效

Ios Firestore的字段路径无效,ios,swift,firebase,google-cloud-firestore,Ios,Swift,Firebase,Google Cloud Firestore,我今天在Firestore中遇到一个错误,因为我试图获取一个带有禁止字符的路径 REF_ROOT.document(currentUser.uid).collection("records").whereField(workoutName, isEqualTo: "Open 16.5 / 14.5").getDocuments 是否可以在斜杠之前添加反斜杠或任何东西(事实上是任何禁止的字符),以便继续此请求 这是我的日志: Invalid field path (Open 16.5 / 14.

我今天在Firestore中遇到一个错误,因为我试图获取一个带有禁止字符的路径

REF_ROOT.document(currentUser.uid).collection("records").whereField(workoutName, isEqualTo: "Open 16.5 / 14.5").getDocuments
是否可以在斜杠之前添加反斜杠或任何东西(事实上是任何禁止的字符),以便继续此请求

这是我的日志:

Invalid field path (Open 16.5 / 14.5). Paths must not contain '~', '*', '/', '[', or ']'
firebase::firestore::util::ObjcThrowHandler(firebase::firestore::util::ExceptionType, char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
无效的字段路径(打开16.5/14.5)。路径不能包含“~”、“*”、“/”、“[”或“]”
firebase::firestore::util::ObjcThrowHandler(firebase::firestore::util::ExceptionType,char const*,char const*,int,std::_1::basic_string const&)

不要将路径与它们指向的字段数据混淆

“Open 16.5/14.5”
是存储在Firestore字段中的完全合法的值

你的问题是

REF_ROOT.document(currentUser.uid).collection("records")
                                  .whereField(workoutName, isEqualTo: "Open 16.5 / 14.5")
                                  .getDocuments
这告诉我
currentUser.uid
workoutName
包含无效字符,很可能是
workoutName

尝试在调用之前打印出来,以查看控制台中打印的内容

print(workoutName) //probably prints this: Open 16.5 / 14.5
REF_ROOT.document(currentUser.uid).collection("records")
                                  .whereField(workoutName, isEqualTo: "Open 16.5 / 14.5")
                                  .getDocuments

你说得对,问题出在别的地方,我的错。非常感谢。