如何从Firebase订购从最新到最旧的图像?

时间:2018-11-07 00:28:49

标签: ios iphone swift firebase firebase-realtime-database

我目前有一个应用程序,将图像上传到Firebase,然后在按下按钮时进行检索。但是,在Firebase中,它们按字母顺序排列。如何使“帖子”从最新到最旧排列? 我的数据库结构:

    {
  "Posts" : {
    "ThisWouldBeRandomUID" : {
      "post:RandomUIDHere" : {
        "ImageUrl" : {
          "image1" : "https://URLHere",
          "image2" : "https://URLHere"
        }
      }
    },
  "users" : {
    "7AM0CeJ71tYON9NejziFZto16fk2" : {
      "email" : "dhhfhfhffhdh@hdhdhdjdh.hehdhdhdh",
      "password" : "dhdhdhhdhdhdhdhdhfhf"
    }
  }
}

1 个答案:

答案 0 :(得分:0)

到目前为止,我在Firebase中没有看到类似的函数,在我的情况下,在获取所有“发布”数据(从最旧到新的排列)之后,我存储了从实时数据库查询返回的“数据”在对象中,并在JavaScript中使用reverse()函数,我成功地将帖子从新旧排序。希望这会有所帮助