質問するログイン新規登録

質問編集履歴

1

現在のコードとやりたいことを追記

2018/06/07 10:17

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -23,4 +23,59 @@
23
23
 
24
24
  そのため、今は代わりにdisplayName, photoURL, Uidなどをそれぞれ別々に保存しております。
25
25
 
26
- 別々に保存することなく、ユーザー情報を保存することは可能でしょうか?
26
+ 別々に保存することなく、ユーザー情報を保存することは可能でしょうか?
27
+
28
+
29
+
30
+ ### 追記
31
+ - 現在のコード
32
+
33
+ ```
34
+ func postStrings() {
35
+ let currentUser = Auth.auth().currentUser
36
+
37
+
38
+ //保存するデータをセット
39
+ let post: [String: Any] = [
40
+ "category": category!,
41
+ "postUid": currentUser.uid,
42
+ "postUserName": currentUser.displayName!,
43
+ "postUserPhotoURL": currentUser.photoURL!,
44
+ "placeName": placeName!,
45
+ "singleWord": singleWord!,
46
+ "createDate": self.date
47
+ ]
48
+ SVProgressHUD.show()
49
+ self.defaultStore.collection("Post").addDocument(data: post) { (error) in
50
+ if let error = error {
51
+ SVProgressHUD.showError(withStatus: error.localizedDescription)
52
+ SVProgressHUD.dismiss()
53
+ } else {
54
+ SVProgressHUD.dismiss()
55
+ SVProgressHUD.showSuccess(withStatus: "投稿完了")
56
+ //閉じる
57
+ self.dismiss(animated: true, completion: nil)
58
+ }
59
+ }
60
+ }
61
+ ```
62
+
63
+ 今、ユーザー名、ユーザーIdを別々のコレクションに保存しています。("postUid","postUserName","postUserPhotoURL")
64
+
65
+ - やりたいこと
66
+ ユーザ情報をいちいち別々に保存することなく、まとめて「ユーザー情報」として保存したいです。
67
+ (ユーザー情報を同じコレクションに保存するイメージ)
68
+ ```
69
+ userInfo
70
+ |--uid
71
+ |--displayName
72
+ |--photoURL
73
+ ````
74
+
75
+
76
+ また、以下のようにすると上記のエラーが出ます。(Unsupported type: FIRUser )
77
+ ```
78
+ let post: [String: Any] = [
79
+ "userInfo": currentUser,
80
+ ]
81
+ ```