angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

FirebaseError. No document to update using set()

Open diegofin opened this issue 8 years ago • 1 comments

Version info

Angular: 6.0.3

Firebase: 5.0.4

AngularFire: 5.0.0-rc.9

Other (e.g. Ionic/Cordova, Node, browser, operating system): Chrome

How to reproduce these conditions

Steps to set up and reproduce

When I try to set an item that didn't exist using the method "set" from angularfire2, I get an error in the console saying:

Error: Uncaught (in promise): FirebaseError: [code=not-found]: No document to update: project...

My line is: this.afs.collection(user).doc(authData.uid).set(userData);

If instead I use the firestore method "set", I don't get that error and it works as expected: this.afs.firestore.collection(user).doc(authData.uid).set(userData);

Debug output

** Errors in the JavaScript console ** Uncaught Error: Uncaught (in promise): FirebaseError: [code=not-found]: No document to update: projects/sample/databases/(default)/documents/user/m1kf5S5iF3r5vlu5BRBG5GYNtEr2 FirebaseError: No document to update: projects/sample/databases/(default)/documents/user/m1kf5S5iF3r5vlu5BRBG5GYNtEr2 at new FirestoreError (index.cjs.js:346) at index.cjs.js:6786 at W.<anonymous> (index.cjs.js:6731) at Ab (index.js:23) at W.push../node_modules/@firebase/webchannel-wrapper/dist/index.js.g.dispatchEvent (index.js:21)

Expected behavior

To be able to use .set from angularfire2 without errors

Actual behavior

Using .set from angularfire2 in an item that didn't exist, throws the error.

The error is not catched either, the "Document successfully written!" message is printed after it throws the error No document to update: this.afs.collection(user).doc(authData.uid).set(userData).then(function() { console.log("Document successfully written!"); }) .catch(function(error) { console.error("Error writing document: ", error); });

diegofin avatar Jul 22 '18 11:07 diegofin

Sorry, my bad, it must be something related to my code that I don't see yet, since I see it happens in both cases I mentioned. Can be closed!

diegofin avatar Jul 22 '18 12:07 diegofin