Environment details
- OS: Linux Mint
- Node.js version: 8.9.4 LTS
- npm version: 5.6.0
- @google-cloud/firestore version: 0.11.2
Steps to reproduce
- call function ref.doc(id).set(params, options), which params is a object like:
{
"notifications": {
"web": "a random token string"
},
"updatedAt": 1519320011313
}
Expected behavior
Actual behavior
- I got error
Cannot encode type ([object Object]) to a Firestore Value. The [object Object] is the nested object ( {web : a random token string} ).
I realized the function isPlainObject at line 1428 returns true for {notifications...}, but returns false for the nested object {web: ....}, as it has no Object.prototype property.
//firestore/src/document.js 1428
function isPlainObject(input) {
return (
typeof input === 'object' &&
input !== null &&
Object.getPrototypeOf(input) === Object.prototype
);
}
When I tried to force input to be an object
function isPlainObject(input) {
return (
typeof input === 'object' &&
input !== null &&
(Object.getPrototypeOf(input) === Object.prototype) || (Object.getPrototypeOf(Object.create(input)) === Object.prototype)
);
}
I got another error for the other value at not nested object:
Argument \"data\" is not a valid Document. Object prototype may only be an Object or null: 1519320772620.
Using lodash 's isObject method:
function isPlainObject(input) {
return require('lodash').isObject(input) //returns true for both objects
}
I got the error
Argument \"data\" is not a valid Document. obj.hasOwnProperty is not a function
How can I handle this problem? Thank you in advance.
Environment details
Steps to reproduce
Expected behavior
Actual behavior
Cannot encode type ([object Object]) to a Firestore Value. The [object Object] is the nested object ({web : a random token string}).I realized the function isPlainObject at line 1428 returns true for {notifications...}, but returns false for the nested object {web: ....}, as it has no Object.prototype property.
//firestore/src/document.js 1428
When I tried to force input to be an object
I got another error for the other value at not nested object:
Argument \"data\" is not a valid Document. Object prototype may only be an Object or null: 1519320772620.Using lodash 's isObject method:
I got the error
Argument \"data\" is not a valid Document. obj.hasOwnProperty is not a functionHow can I handle this problem? Thank you in advance.