CollectionReference.doc()要求其第一个参数的类型为非空字符串 [英] CollectionReference.doc() requires its first argument to be of type non-empty string

查看:40
本文介绍了CollectionReference.doc()要求其第一个参数的类型为非空字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个离子应用程序正在尝试更新Firebase中的记录.我不断收到此错误.不知道我在做什么错.

错误:未捕获(承诺):FirebaseError:[code = invalid-argument]:函数CollectionReference.doc()要求其第一个参数的类型为非空字符串,但它是:自定义Object对象

FirebaseError:函数CollectionReference.doc()要求其第一个参数为非空字符串类型,但它是:一个自定义Object对象

这是我的更新功能.

  updateTodo(todo:待办事项,id:字符串){返回this.todosCollection.doc(id).update(todo)} 

解决方案

就我而言,我在.doc函数中传递了数字类型变量,但它需要一个字符串.验证您的"id"是否正确变量具有一个值,并且不是不确定的,为null或为空的字符串.

I have an ionic app trying to update the records in firebase. I keep on getting this error. Not sure what I am doing wrong.

Error: Uncaught (in promise): FirebaseError: [code=invalid-argument]: Function CollectionReference.doc() requires its first argument to be of type non-empty string, but it was: a custom Object object

FirebaseError: Function CollectionReference.doc() requires its first argument to be of type non-empty string, but it was: a custom Object object

this is my update function.

updateTodo(todo: Todo, id: string) {

    return this.todosCollection.doc(id).update(todo)
}

解决方案

In my case I was passing a number type variable in the .doc function but it requires a string. Verify that your "id" variable has a value and it is not undefined, null or and empty string.

这篇关于CollectionReference.doc()要求其第一个参数的类型为非空字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆