Display posts in descending posted order

前端 未结 18 1149
南方客
南方客 2020-11-22 11:47

I\'m trying to test out Firebase to allow users to post comments using push. I want to display the data I retrieve with the following;

fbl.child         


        
18条回答
  •  自闭症患者
    2020-11-22 12:17

    You are searching limitTolast(Int x) .This will give you the last "x" higher elements of your database (they are in ascending order) but they are the "x" higher elements

    if you got in your database {10,300,150,240,2,24,220}

    this method:

    myFirebaseRef.orderByChild("highScore").limitToLast(4)
    

    will retrive you : {150,220,240,300}

提交回复
热议问题