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

Document firebase-document workaround to immutability of firebase-query #104

Open
miztroh-zz opened this issue Aug 25, 2016 · 3 comments
Open

Comments

@miztroh-zz
Copy link

@cdata Mentions using firebase-document as a means of adding a new item to an array being queried by firebase-query. As the results of the query are immutable, this is a key piece of functionality in trying to get back to what could be accomplished through the old firebase-collection. See #15.

@43081j
Copy link
Contributor

43081j commented Aug 30, 2016

As a workaround, you can programatically add a document:

var doc = this.create('firebase-document', {
  data: newDoc
});

doc.save('/foo/path');

This will actually do a firebase push(...) on /foo/path, so newDoc will be added with a generated ID. Your firebase-query will pick this change up too.

Also the reason I create the element instead of have it in the template... this is because after calling save(...), the path will be set. So all future save(...) calls will try update the same item rather than push a new one.

@alejohann
Copy link

alejohann commented Sep 5, 2016

I was waiting for an answer like that for weeks!

@mbleigh
Copy link
Contributor

mbleigh commented Sep 9, 2016

Starting some thinking about how we could do this "for real" in a more built-in way. #112 offers online-only methods that work directly with the Firebase SDK, but I don't think I'd like to merge it until I can rationalize it with offline behavior.

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

4 participants