this.unsubscribe = this.refAssign.where(‘email’, ‘==’, this.state.user.email ).onSnapshot(this.onCollectionUpdate);
FirebaseError: Function Query.where() 需要一个有效的第三个参数,但它是未定义的。
我收到了这条消息。我应该为第三个参数写什么,因为我希望它返回与“分配”集合中具有相同电子邮件的每个“用户”?
this.unsubscribe = this.refAssign.where(‘email’, ‘==’, this.state.user.email ).onSnapshot(this.onCollectionUpdate);
FirebaseError: Function Query.where() 需要一个有效的第三个参数,但它是未定义的。
我收到了这条消息。我应该为第三个参数写什么,因为我希望它返回与“分配”集合中具有相同电子邮件的每个“用户”?
this.state.user.email在调用此语句之前确保存在。
经过多次尝试和错误,我发现使用“where”子句无法做到这一点
`componentDidMount() {
this.unsubscribe1 = this.ref.onSnapshot(this.onCollectionUpdate1);
this.unsubscribe2 = this.refAssign.where(‘email’, ‘==’, this.state.user.email ).onSnapshot(this.onCollectionUpdate2);
}`
而不是那个,我在渲染中比较它使用 condition ? true : false
{this.state.user.map(user =>
<tr>
<td><Link to={`/show/${user.key}`}>{user.email}</Link></td>
<td>{user.name}</td>
<td>{user.authority}</td>
<td>
{this.state.assign.map(assign =>
<p>{assign.email == user.email ? assign.projNo : null }</p>
)}
</td>
</tr>
)}
// 创建对集合的查询。var query = cityRef.where("state", "==", "CA");
确保电子邮件不为空或为空