Issue
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);
Solution
In case someone else bump into the same issue, the solution is to simply use JSON to instantiate the object, like this:
var myDoc = {
Public: {
Name: "Jonh Doe"
}
} as MyDoc; //keep type to still get typescript compiler validations
Answered By - MiguelSlv
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.