我有一系列的键导致我的社交网络的帖子对象像/ posts/id /(发布信息)
当我加载帖子时,我使用observeSingleEventOfType(.Value)方法加载/发布/ 0然后/ posts/1等.
我使用lazyTableView一次加载30并且速度很慢.有没有什么方法可以使用其中一种查询方法或其他方法使其更快,即使我必须重构我的JSON树中的数据.
我来自Parse重新实现我的应用程序,到目前为止,经验非常好.只有这一点我有点坚持.在此先感谢您的帮助!
编辑:
func loadNext(i: Int) {
// check if exhists
let ideaPostsRef = Firebase(url: "https://APPURL")
ideaPostsRef.childByAppendingPath(i.description).observeSingleEventOfType(.Value, withBlock: {
(snapshot) in
if i % 29 == 0 && i != 0 && !self.hitNull { return }
// false if nil
// true if not nil
if !(snapshot.value is NSNull) {
let postJSON = snapshot.value as! [String: AnyObject]
print("GOT VALID \(postJSON)")
let post = IdeaPost(message: postJSON["message"] as! String, byUser: postJSON["user"] as! String, withId: i.description)
post.upvotes …Run Code Online (Sandbox Code Playgroud) 我试图在方法中使用'OR' ||语句equalTo(),但这似乎不起作用.我是否必须为每个值单独调用,或者是否有办法在firebase中进行条件查询?
export const startSetContent = () => {
return (dispatch, getState) => {
const ref = database.ref("content");
return ref
.orderByChild("category")
.equalTo('one-act-play' || 'ten-min-play' || 'full-length-play')
.once('value')
.then(snapshot => {
const content = [];
snapshot.forEach(childSnapshot => {
content.push({
id: childSnapshot.key,
...childSnapshot.val()
});
});
dispatch(setContent(content));
});
};
};
Run Code Online (Sandbox Code Playgroud) 是否有任何方法可以在Firebae上过滤数组中的数据?
我的Firebase上有这个型号:
-KABIGeWnBMUKjLTcvp8
deviceToken:"7DE60240CB4B712F05A009F32358610C1327917E7E68409..."
favorites
0:"Masha"
1:"moksha"
name:"juan"
Run Code Online (Sandbox Code Playgroud)
问题是我找不到任何方法来获取"favorites"数组字段中包含特定值的所有"用户".