-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Firestore document .update() not working as intended #1245
Comments
Not only the partial typescript issue but it appears .update() is not creating a document if it doesn't already exist. .set() works.
|
According to the Node.js documentation for "Set a document" at https://firebase.google.com/docs/firestore/manage-data/add-data:
I couldn't find that feature documented anywhere, but tried appending "create: true" to the update request and it works swimmingly.
|
@itjustwerks can you tell me why using "angularfire2": "^5.0.0-rc.3",
|
Ok I got it:
|
@Azmos , my bad. The {create: true} 2nd parameter is only applicable to the firebase-admin Node.js library for some reason. I just tried it myself for the web today and got the same error as you. I ended up doing the set in the catch block if there was an error on the update, but your solution is better for sure. Thanks! |
It seems you can also do:
As documented here: https://firebase.google.com/docs/firestore/manage-data/add-data Am I missing something which would make this different than EDIT: Nevermind, this project uses the NodeJS client instead of the web client. (odd that they would implement |
Tried once again and neither of them work on my code, in my case checking "manually" if the document exists is the only way to achieve that. |
Tried once again and neither of them work on my code, in my case checking "manu |
Version info
Angular: 4.3
Firebase: 4.5.0
AngularFire: 5.0 rc1
Other (e.g. Ionic/Cordova, Node, browser, operating system):
How to reproduce these conditions
https://stackblitz.com/edit/angular-abcgfq?file=app%2Fapp.component.ts
I think stackblitz is having trouble with the AngularFire2 import, if you get the red squiggly under
angularfire2/firestore
go to dependencies, delete the library and re-installSteps to set up and reproduce
Create an
AngularFirestoreDocument
call.update()
on it with a single field (of a larger object) and it is not accepted.Sample data and security rules n/a
<-- include/attach/link to some json sample data (or provide credentials to a sanitized, test Firebase project) -->
Debug output
** Errors in the JavaScript console **
** Output from
firebase.database().enableLogging(true);
**** Screenshots **
Expected behavior
I would expect that I can update a single field on a larger object as per the Firestore docs
Actual behavior
Typescript is telling me:
That is to say, "We're looking for you to pass in the whole Post object, not just one field."
The text was updated successfully, but these errors were encountered: