如何在Firebase中对数据进行排序?

时间:2017-03-17 18:04:40

标签: ios swift firebase firebase-realtime-database

所以我尝试将大多数喜欢的数据排序到最少。如果没有对象名称,我该怎么做?因为目前我只有对象的ID?

这是我的Firebase json:

["-KfSODzRPjy46ayCFRBH": {
      "_createdAt" = 1489773065234;
      "_updatedAt" = 1489773065234;
      content =     (
                     "<null>",
                     Tittle,
                     "why not there is the nnnd ksksks lalalalalkdkdkdkdk kadsjfakl;",
                     whhhhhhalalallala
                    );
      imageTitle = 1489773064177;
      like = 2;
      title = "Third Post";
}, 

["-KfSODzRPjy46ayCFRBH": {
      "_createdAt" = 1489773065234;
      "_updatedAt" = 1489773065234;
      content =     (
                     "<null>",
                     Tittle,
                     "why not there is the nnnd ksksks lalalalalkdkdkdkdk kadsjfakl;",
                     whhhhhhalalallala
                    );
      imageTitle = 1489773064177;
      like = 3;
      title = "Third Post";
}, 

这就是我的阅读方式:

        let handleref = databaseRef.child("v1/postmodel").observe(.value, with: { (snapshot) in
        let postDict = snapshot.value as! [String : AnyObject]
        print(postDict)
    })

0 个答案:

没有答案