火力->日期顺序反转 [英] firebase -> date order reverse
问题描述
我目前正在使用 Firebase 制作应用.
I am currently making an app using Firebase.
这是可以在网络上的任何地方看到的公告板之一.
It is one of those bulletin boards that can be seen anywhere on the web.
但是有一个问题.
这是一个日期排序的问题.
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);
})
结果 - >hello1496941142093
我的 firebase 树
My firebase tree
我的代码和上面一样.
如何先查看我最近的帖子?
How can I check my recent posts first?
如何对 firebase 数据库进行反向排序?
How Do I order reverse of firebase database?
推荐答案
Firebase 数据库将始终按升序返回结果.没有办法扭转它们.
The Firebase Database will always return results in ascending order. There is no way to reverse them.
有两种常见的解决方法:
There are two common workaround for this:
- 让数据库进行过滤,然后在客户端反转结果.
- 向数据库添加反向值,并将其用于查询.
这些选项之前已经讨论过很多次了.因此,与其重复,我将列出以前的答案:
These options have been covered quite a few times before. So instead of repeating, I'll give a list of previous answers:
- 以降序显示帖子
- 使用负时间戳按降序对 firebase 数据进行排序一个>
- firebase 倒序排序
- 是否可以反转 Firebase 列表?
- 此列表中的更多内容:https://www.google.com/search?q=site:stackoverflow.com+firebase+reverse%20sort%20javascript
这篇关于火力->日期顺序反转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!