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

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

问题描述

我目前正在使用 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:

  1. 让数据库进行过滤,然后在客户端反转结果.
  2. 向数据库添加反向值,并将其用于查询.

这些选项之前已经讨论过很多次了.因此,与其重复,我将列出以前的答案:

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

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

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