I am trying to fetch a document from a collection using the document ID, which works by the way, and trying to save the document to a new collection. I have 2 requirements, depending on the user input either to use replace the document if the ID exists or create a altogether new document with new document id. Given below is my code.
I get the following error. Any help!
Error: Value for argument "data" is not a valid Firestore document. Detected an object of type "DocumentReference" that doesn't match the expected instance. Please ensure that the Firestore types you are using are from the same NPM package.)
at validateDocumentData (/srv/node_modules/@google-cloud/firestore/build/src/write-batch.js:608:15)
at WriteBatch.set (/srv/node_modules/@google-cloud/firestore/build/src/write-batch.js:232:9)
at DocumentReference.set (/srv/node_modules/@google-cloud/firestore/build/src/reference.js:330:14)
at req.body.items.forEach.item (/srv/index.js:92:54)
at Array.forEach (<anonymous>)
at app.put (/srv/index.js:86:24)
at Layer.handle [as handle_request] (/srv/node_modules/express/lib/router/layer.js:95:5)
at next (/srv/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/srv/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/srv/node_modules/express/lib/router/layer.js:95:5)