firebase - >日期顺序反转 [英] firebase -> date order reverse

查看:178
本文介绍了firebase - >日期顺序反转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Firebase制作应用。



这是其中一个可以在网络上看到的公告板。



但是有一个问题。



这是日期排序问题。



<我想先看看最近的日期,但我总是只看到我先创建的数据。

  postRef.orderByChild('createData')。startAt(reverseDate).limitToFirst(1).on('child_added',( data)=> {
console.log(data.val()。name + data.val()。createData);
})

结果 - > hello1496941142093



我的火力基地树



我的代码与上述代码相同。



如何查看我最近的帖子?



如何订购firebase数据库的反转?

解决方案

Firebase数据库将始终按升序返回结果。没有办法扭转它们。



这有两种常见的解决方法:


  1. 让数据库进行过滤,然后反转客户端的结果。

  2. 向数据库添加反转值,并使用它进行查询。

这些选项之前已被覆盖过很多次。因此,我不会重复,而是列出以前的答案:




I am currently making an app using Firebase.

It is one of those bulletin boards that can be seen anywhere on the web.

But there was one problem.

This is a matter of date sorting.

I want to look at the recent date first, but I always see only the data I created first.

postRef.orderByChild('createData').startAt(reverseDate).limitToFirst(1).on('child_added',(data)=>{
    console.log(data.val().name + data.val().createData);
})

result - >hello1496941142093

My firebase tree

My code is the same as above.

How can I check my recent posts first?

How Do I order reverse of firebase database?

解决方案

The Firebase Database will always return results in ascending order. There is no way to reverse them.

There are two common workaround for this:

  1. Let the database do the filtering, but then reverse the results client-side.
  2. Add an inverted value to the database, and use that for querying.

These options have been covered quite a few times before. So instead of repeating, I'll give a list of previous answers:

这篇关于firebase - &gt;日期顺序反转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆