Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$firebaseUtils.toJSON() drops keys starting with underscore #901

Closed
rala72 opened this issue Jan 13, 2017 · 1 comment
Closed

$firebaseUtils.toJSON() drops keys starting with underscore #901

rala72 opened this issue Jan 13, 2017 · 1 comment

Comments

@rala72
Copy link

rala72 commented Jan 13, 2017

Version info

Angular: 1.5.6
Firebase: 3.6.2
AngularFire: 2.2.0

Issue

StackOverflow question

@rala72 rala72 closed this as completed Jan 13, 2017
@katowulf
Copy link
Contributor

katowulf commented Jan 13, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants