[英]Why is my object being treated as a ql object?
When I try to use Firebase.Firestore.set() with an object, I get an error saying "(FirebaseError): Function DocumentReference.set() called with invalid data. Unsupported field value: a custom ql object" 当我尝试将Firebase.Firestore.set()与对象一起使用时,出现错误消息“(FirebaseError):函数DocumentReference.set()调用了无效数据。不支持的字段值:自定义ql对象”
I'm using Firebase in a React class, and I tried creating the object right in the function and defining it separately as shown below: 我在React类中使用Firebase,并且尝试在函数中直接创建对象并分别定义,如下所示:
if (authUser) {
const userObj = {
name: authUser.displayName,
uid: authUser.uid,
email: authUser.email,
emailVerified: authUser.emailVerified,
providerData: authUser.providerData
}
this.db.collection("users").doc(authUser.uid).set(userObj, { merge: true })
}
Your problem is that you are trying to copy an instance of an object, (i guess is a graphql object) and firebase does not support that, you need to use primitive values. 您的问题是,您正在尝试复制对象的实例(我猜是graphql对象),而Firebase不支持该实例,则需要使用原始值。 Make sure you copy strings on all the properties instead of pointers to the class.
确保在所有属性上复制字符串,而不是指向类的指针。
Most likely the providerData
(which comes from the identity provider) contains data of a type that Firestore can't handle. 最有可能的
providerData
(来自身份提供者)包含Firestore无法处理的类型的数据。 To fix this problem, either don't store the provider data, or convert it into a compatible type with this hack: 要解决此问题,请不要存储提供程序数据,或者将其转换为与此hack兼容的类型:
providerData: JSON.parse(JSON.stringify(authUser.providerData))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.