Firebase: .priority value

前端 未结 5 1141
半阙折子戏
半阙折子戏 2021-02-20 05:44
  • How do I check the .priority values are in my \"Forge\"?
  • According to docs, smaller .priority value comes before larger .priority value. If I use seconds since ep
相关标签:
5条回答
  • 2021-02-20 06:00

    You can see .priority in a json by "Export JSON" from the Forge.

    0 讨论(0)
  • 2021-02-20 06:05

    use

    snapshot.getPriority();
    

    more at https://www.firebase.com/docs/javascript/firebase/setwithpriority.html

    0 讨论(0)
  • 2021-02-20 06:08

    It's not available from Forge but you can see it from the JSON format:

    https://YOURAPP.firebaseio.com/.json?print=pretty&format=export

    0 讨论(0)
  • There's no way in Forge right now to see the actual priority values, but the children will be sorted correctly.

    If what you want is to sort items in reverse-chronological-order, I'd suggest simply setting the priority to a normal timestamp (or using push -- it orders them automatically). You can then simply render them backwards to achieve the reverse order you want. For example, rather than appending new messages to the bottom of a list in your app, you could insert them before the first element.

    0 讨论(0)
  • 2021-02-20 06:21

    snapshot.exportVal()

    Exports the entire contents of the DataSnapshot as a Javascript object. This is similar to val(), except priority information is included (if available), making it suitable for backing up your data.

    The export format is a Javascript object with ".priority" entries added to any object with a priority. In the case of primitive values (a string, number, or boolean) with a priority, the value is wrapped in an object with ".value" and ".priority" properties. In the case of primitive values without a priority, a primitive value is returned.

    Source: https://www.firebase.com/docs/web/api/datasnapshot/exportval.html

    0 讨论(0)
提交回复
热议问题