Skip to content

Updating object #190

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

Closed
pfried opened this issue May 25, 2016 · 2 comments
Closed

Updating object #190

pfried opened this issue May 25, 2016 · 2 comments

Comments

@pfried
Copy link

pfried commented May 25, 2016

This may be more a kind of general firebase question, but as it is angular specific, i wanted to ask how to handle updates in general.

Often you have small objects like:

class Meeting {
  place: string;
  leader: string;
}

which you then bind to an input element with ngModel. My question now: Is there a recommended way of updating the record?

Atomical updates are ideal, but imho sometimes not very useful since i think i would need a fair amount of code to get these atomic updates from the model. In the upper case i might like to update the model as a whole like

meetings.update(meeting.$key, meeting);

This leads to the following problem:

1.) The $key property is still on the meeting object and will cause an error because the key contains forbidden characters ($)

Now i could the following:

meetings.update(meeting.$key, { place: meeting.place, leader: meeting.leader });

2.) If one of the properties is undefined i will get an error

1.) could be solved by deleting the $key property on update. This might not be an elegant solution, so dont worry too much about it.

My Idea would be creating a directive which binds to a FirebaseObservable and does the atomic updates, but anyhow: Is there a way to do updates in a recommended way?

@nelsonad
Copy link

I'm curious about this too.

@davideast
Copy link
Collaborator

Right now the best option is to manually delete the $key property. In the future we'll look at supporting this in the library, but right now we are focused on getting it aligned with RC3 and supporting new Firebase features.

See #197 for a sample of how to handle it.

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

No branches or pull requests

3 participants