I am getting the error
Error: Argument "data" is not a valid Document. Input is not a plain JavaScript object.
when updating a document, using firebase admin SDK. Here the Typescript code.
var myDoc = new MyDoc();
myDoc.Public.Name = "Jonh Doe" //setup up content
admin.firestore()
.collection('MyDocs')
.doc("Id1")
.set(myDoc);
I did something similar:
var myDoc = <MyDoc> {
Public: {
Name: "Jonh Doe"
}
}
It is semantically the same, I just think it is a bit cleaner.
In case some else bump into the same issue, the solution is to simple use Json to instantiate the object, like this:
var myDoc = {
Public: {
Name: "Jonh Doe"
}
} as MyDoc; //keep type to still get typescript compiler validations
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With