FirebaseExtended / angularfire

AngularJS bindings for Firebase

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

$firebaseUtils.toJSON() drops keys starting with underscore

rala72 opened this issue · comments

commented

Version info

Angular: 1.5.6
Firebase: 3.6.2
AngularFire: 2.2.0

Issue

StackOverflow question

This was a design decision, based on the fact that a common JavaScript convention for declaring private variables is to prefix them with _.

For context on why it's different than the default SDK behavior, keep in mind that AngularFire is creating class instances that can be extended, and provide client-side functionality (not just raw JSON objects for data transfer). So our goal here is to make it as simple and straightforward as possible to extend and use $firebaseArray and $firebaseObject, and to make saving and server sync as transparent as possible.

To do so, you need a simple convention to separate "local" or private things from ones you want sent to the server. Since $ is technically reserved by the Angular libs, _ continues to be the appropriate way to prefix your private variables and methods pre-ES6.

We could revisit if there were significant numbers of people having issues here, but given that it's been implemented this way nearly 3 years and this is the first comment on it, I suspect it's fine as is.