【发布时间】:2020-03-25 09:52:23
【问题描述】:
我现在想归档聊天,因此用户只能看到他是聊天成员的聊天。 如您所见,每个聊天都有成员节点,有来自 firebase 的 userId。 我如何在我的请求中过滤它? 现在我检索这样的聊天记录:
constructor(props) {
super(props);
this.state = { chats: [] };
this.getChats = this.getChats.bind(this);
}
componentDidMount() {
var _userId = firebase.auth().currentUser.uid;
this.getChats(_userId);
}
getChats = _userId => {
var readedData = firebase
.database()
.ref('chats')
.orderByKey();
readedData.once('value', snapshot => {
this.setState({ chats: snapshot.val() });
console.log(this.state.chats);
});
};
【问题讨论】:
标签: reactjs firebase firebase-realtime-database