質問編集履歴

4

試して見たことで進捗を追記しました

2018/08/11 10:06

投稿

yamady
yamady

スコア176

test CHANGED
File without changes
test CHANGED
@@ -100,13 +100,23 @@
100
100
 
101
101
  const userPromises = items.map((item, itemId) => {
102
102
 
103
- console.log('item:', item);
104
-
105
103
  const userId = item.userId;
106
104
 
107
- return firebase.firestore().collection('users').doc(userId).get()
105
+ console.log('userId: ', userId);
108
106
 
107
+ return firebase.firestore().collection('users').get(userId)
108
+
109
- .then(snapshot => snapshot.doc())
109
+ .then((snapshot) => {
110
+
111
+ console.log('snapshot:', snapshot);
112
+
113
+ const user = snapshot.docs.data();
114
+
115
+ return user;
116
+
117
+ console.log('user:', user);
118
+
119
+ })
110
120
 
111
121
  .then(user => ({...item, user: user, itemId}));
112
122
 
@@ -145,3 +155,17 @@
145
155
  ```
146
156
 
147
157
  ユーザーidを合わせてみることをしてみましたが、やはり取ることはできませんでした。
158
+
159
+
160
+
161
+ ### 追記
162
+
163
+ get()の中にuserIdを入れることで、snapshotに正常な値が入るようになったのですが、今度は下記のエラーでつまってしまっています。。
164
+
165
+
166
+
167
+ ```
168
+
169
+ Error: Query.get failed: First argument must be an object.
170
+
171
+ ```

3

試してみたことを追記しました

2018/08/11 10:06

投稿

yamady
yamady

スコア176

test CHANGED
File without changes
test CHANGED
@@ -131,3 +131,17 @@
131
131
  snapshotの部分を試行錯誤してみて、なんとか次を表示しようと頑張っているのですが今回のエラーが出てしまい解決できていません。
132
132
 
133
133
  おたすけくださいませ。
134
+
135
+
136
+
137
+ ### 追記
138
+
139
+
140
+
141
+ ```
142
+
143
+ return firebase.firestore().collection('users', '==', userId).get()
144
+
145
+ ```
146
+
147
+ ユーザーidを合わせてみることをしてみましたが、やはり取ることはできませんでした。

2

ソースコードを更新しました

2018/08/11 09:56

投稿

yamady
yamady

スコア176

test CHANGED
File without changes
test CHANGED
@@ -15,8 +15,6 @@
15
15
  return (dispatch) => {
16
16
 
17
17
  firebase.database().ref(`/items/`)
18
-
19
- .orderByChild(dayOfWeekStr).equalTo(true)
20
18
 
21
19
  .once('value', snapshot => {
22
20
 

1

ソースコードを更新しました。

2018/08/11 09:25

投稿

yamady
yamady

スコア176

test CHANGED
File without changes
test CHANGED
@@ -100,13 +100,13 @@
100
100
 
101
101
  .then((items) => {
102
102
 
103
- const userPromises = items.map((item) => {
103
+ const userPromises = items.map((item, itemId) => {
104
104
 
105
105
  console.log('item:', item);
106
106
 
107
- console.log('userId:', item.userId);
107
+ const userId = item.userId;
108
108
 
109
- return firebase.firestore().collection('users').doc(item.userId).get()
109
+ return firebase.firestore().collection('users').doc(userId).get()
110
110
 
111
111
  .then(snapshot => snapshot.doc())
112
112