-
Notifications
You must be signed in to change notification settings - Fork 373
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
Cloud Firestore node.js invalid use of type “object” as a Firestore argument #618
Comments
I found a few problems with this issue:
|
@kiwicopple Thanks for sending this over. Can you run the following on your local machine:
For me this prints:
|
Thanks for the swift response @schmidt-sebastian After sleeping on this I think it may be better/easier to solve this within the library using For more context and anyone who reads this, here was my solution The issue is with the library above is that they do an // See line 44 of the above where msg.payload = { "foo": "bar", "user": { "_id", 1000 } }
const payload = this.preparePayload(msg.payload)
// Top level has a "prototype"
console.log('Prototype matches: ' + (Object.getPrototypeOf(obj) === Object.prototype));
// -> Prototype matches: true
// Nested objects don't
console.log('Prototype matches: ' + (Object.getPrototypeOf(obj.user) === Object.prototype));
// -> Prototype matches: false
console.log('Node version: ' + process.version);
// -> Node version: v8.16.0 - note this was different to my environment a NodeRed was running in a docker container And I think the only way to solve it is to call Thanks for the help @schmidt-sebastian - I'll close this for now |
[REQUIRED] Step 2: Describe your environment
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
This issue (by someone else) describes both the problem and the resolution: https://stackoverflow.com/questions/55065567/cloud-firestore-node-js-invalid-use-of-type-object-as-a-firestore-argument
For prosperity, I am facing the same problem using Node-Red to send a JSON object like this:
Which is then called in the function:
And throws the error:
The workaround, as the SO thread explains is to edit
node_modules/@google-cloud/firestore/build/src/serializer.js
and change
isPlainObject
toIs there a more permanent solution that I can use? This is fine on my development environment, but I will need to deploy this to an environment where I cannot edit node_modules
Many thanks
The text was updated successfully, but these errors were encountered: