Display posts in descending posted order

前端 未结 18 945
南方客
南方客 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 11:56

    There is a better way. You should order by negative server timestamp. How to get negative server timestamp even offline? There is an hidden field which helps. Related snippet from documentation:

    var offsetRef = new Firebase("https://.firebaseio.com/.info/serverTimeOffset");
      offsetRef.on("value", function(snap) {
      var offset = snap.val();
      var estimatedServerTimeMs = new Date().getTime() + offset;
    });
    

提交回复
热议问题