(some keys are automatically generated by Firebase, some of them were created by me)
No, properties order in objects is not guaranteed in JavaScript; you need to use an Array
While the array isn't technically read-only, it has some special requirements for modifying the structure (removing and adding items) which we will cover below. Please read through this entire section before trying any slicing or dicing of the array.
Because of this special arrangement, AngularFire provides the concurrency safe $add(), $remove(), and $save() methods to modify the array and its elements.
Using methods like splice(), pop(), push(), shift(), and unshift() will probably work for modifying the local content, but those methods are not monitored by AngularFire and changes introduced won't affect the content or order on the remote server. Therefore, to change the remote data, the concurrency-safe methods should be used instead.
Methods like splice(), push(), pop(), shift(), unshift(), and reverse() will cause the local data to become out of sync with the server. Instead, utilize the $add(), $remove(), and $save() methods provided by the service to change the structure of the array.
[
{ sortKey: "a"},
{ sortKey: "b"},
{ sortKey: "c"},
{ sortKey: "d"}
]
--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/bb83b5c0-ca25-4138-b976-2321295033fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Each lesson contains some content.
Later on I want other users to create new content and reorder it.
I think that Array might be a more suitable structure to hold the data,
I'm just a little bit unsure - how to allow reordering?
First thoughts how to solve this issue:
Each element of the array contains a sortKey - either a named field or setPriority()
Is there a reason we can't just solve the ordering problem by adding a sort field and utilizing [orderByChild](https://www.firebase.com/docs/web/guide/retrieving-data.html#section-queries)?
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/73ca464f-eca0-4eec-b0e9-9895a84a287f%40googlegroups.com.